Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: verify all packages have the same engine requirement #9871

Merged
merged 5 commits into from Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -132,7 +132,7 @@ module.exports = {
'**/__mocks__/**',
'**/?(*.)(spec|test).js?(x)',
'scripts/**',
'eslintImportResolver.js',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was used for flow type alias imports

'babel.config.js',
'testSetupFile.js',
],
},
Expand Down
11 changes: 8 additions & 3 deletions babel.config.js
Expand Up @@ -5,6 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

const semver = require('semver');
const pkg = require('./package.json');

const supportedNodeVersion = semver.minVersion(pkg.engines.node).version;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preset-env doesn't support semver operators, so this is used to get the actual minimum version as a string (resolves to 8.3.0)


module.exports = {
babelrcRoots: ['examples/*'],
// we don't wanna run the transforms in this file over react native
Expand All @@ -15,7 +20,7 @@ module.exports = {
'babel-plugin-typescript-strip-namespaces',
'babel-plugin-replace-ts-export-assignment',
require.resolve(
'./scripts/babel-plugin-jest-replace-ts-require-assignment.js'
'./scripts/babel-plugin-jest-replace-ts-require-assignment.js',
),
],
presets: ['@babel/preset-typescript'],
Expand All @@ -31,7 +36,7 @@ module.exports = {
{
exclude: ['@babel/plugin-proposal-dynamic-import'],
shippedProposals: true,
targets: {node: '8.3'},
targets: {node: supportedNodeVersion},
},
],
],
Expand All @@ -48,7 +53,7 @@ module.exports = {
'@babel/preset-env',
{
shippedProposals: true,
targets: {node: '8.3'},
targets: {node: supportedNodeVersion},
},
],
],
Expand Down
2 changes: 1 addition & 1 deletion e2e/coverage-handlebars/__tests__/greet.js
Expand Up @@ -8,6 +8,6 @@ const greet = require('../greet.hbs');

test('am', () => {
expect(greet({am: true, name: 'Joe'})).toEqual(
'<p>Good\n morning\nJoe!</p>\n'
'<p>Good\n morning\nJoe!</p>\n',
);
});
2 changes: 1 addition & 1 deletion e2e/coverage-report/notRequiredInTestSuite.js
Expand Up @@ -7,7 +7,7 @@

throw new Error(
`this error should not be a problem because` +
`this file is never required or executed`
`this file is never required or executed`,
);

// Flow annotations to make sure istanbul can instrument non ES6 source
Expand Down
2 changes: 1 addition & 1 deletion e2e/custom-test-sequencer/testSequencerAsync.js
Expand Up @@ -13,7 +13,7 @@ class CustomSequencer extends Sequencer {
setTimeout(() => {
const copyTests = Array.from(tests);
resolve(
copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1))
copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)),
);
}, 50);
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/each/__tests__/describeOnly.test.js
Expand Up @@ -23,5 +23,5 @@ describe.each([[false, true]])(
it('fails', () => {
expect(left).toBe(right);
});
}
},
);
4 changes: 2 additions & 2 deletions e2e/each/__tests__/eachException.test.js
Expand Up @@ -13,7 +13,7 @@ it.each`
'throws exception when one argument too few are supplied $left == $right',
({left, right}) => {
expect(left).toBe(right);
}
},
);

it.each`
Expand All @@ -23,5 +23,5 @@ it.each`
'throws exception when not enough arguments are supplied $left == $right',
({left, right}) => {
expect(left).toBe(right);
}
},
);
2 changes: 1 addition & 1 deletion e2e/each/__tests__/eachOnly.test.js
Expand Up @@ -37,5 +37,5 @@ it.each`
'Should not be ran: fails all rows expected $left == $right',
({left, right}) => {
expect(left).toBe(right);
}
},
);
2 changes: 1 addition & 1 deletion e2e/each/__tests__/eachSkip.test.js
Expand Up @@ -35,7 +35,7 @@ it.skip.each`
'Should not be ran: fails all rows expected $left == $right',
({left, right}) => {
expect(left).toBe(right);
}
},
);

describe.skip.each([
Expand Down
10 changes: 5 additions & 5 deletions e2e/each/__tests__/failure.test.js
Expand Up @@ -27,7 +27,7 @@ it.each`
'template table fails on one row expected: $left == $right',
({left, right}) => {
expect(left).toBe(right);
}
},
);

it.each`
Expand All @@ -38,14 +38,14 @@ it.each`
'template table fails on all rows expected: $left == $right',
({left, right}) => {
expect(left).toBe(right);
}
},
);

test.each(['red', 'green', 'bean'])(
"The word %s contains the letter 'z'",
word => {
expect(/z/.test(word)).toBe(true);
}
},
);

describe.each`
Expand All @@ -58,7 +58,7 @@ describe.each`
it('fails ', () => {
expect(left).toBe(right);
});
}
},
);

describe.each([
Expand All @@ -70,5 +70,5 @@ describe.each([
it('fails', () => {
expect(left).toBe(right);
});
}
},
);
2 changes: 1 addition & 1 deletion e2e/each/__tests__/success.test.js
Expand Up @@ -9,7 +9,7 @@ test.each(['red', 'green', 'bean'])(
"The word %s contains the letter 'e'",
word => {
expect(/e/.test(word)).toBe(true);
}
},
);

it.each([
Expand Down
Expand Up @@ -8,6 +8,6 @@

test('jasmine.objectContaining', () => {
expect({input: 'trash', output: 'trash'}).toEqual(
jasmine.objectContaining({output: 'trash'})
jasmine.objectContaining({output: 'trash'}),
);
});
2 changes: 1 addition & 1 deletion e2e/expect-async-matcher/__tests__/failure.test.js
Expand Up @@ -20,5 +20,5 @@ it('fail with expected promise values', () =>

it('fail with expected promise values and not', () =>
expect(Promise.resolve([1, 2])).resolves.not.toHaveLengthAsync(
Promise.resolve(2)
Promise.resolve(2),
));
2 changes: 1 addition & 1 deletion e2e/expect-async-matcher/__tests__/success.test.js
Expand Up @@ -20,5 +20,5 @@ it('works with expected promise values', () =>

it('works with expected promise values and not', () =>
expect(Promise.resolve([1, 2])).resolves.not.toHaveLengthAsync(
Promise.resolve(1)
Promise.resolve(1),
));
2 changes: 1 addition & 1 deletion e2e/expect-async-matcher/matchers.js
Expand Up @@ -8,7 +8,7 @@

export async function toHaveLengthAsync(
received: any,
lengthPromise: Promise<number>
lengthPromise: Promise<number>,
) {
const length = await lengthPromise;

Expand Down
4 changes: 2 additions & 2 deletions e2e/expect-in-vm/__tests__/expect-in-vm.test.js
Expand Up @@ -14,7 +14,7 @@ it('correctly expects RegExp inside a new VM context', () => {
`(function(require, module, exports, __dirname, __filename, expect) {
expect('ab12cd').toMatch(/ab12cd/);
})`,
global
global,
);

const module = {
Expand All @@ -28,6 +28,6 @@ it('correctly expects RegExp inside a new VM context', () => {
module.exports,
__dirname,
__filename,
expect
expect,
);
});
2 changes: 1 addition & 1 deletion e2e/jasmine-async/__tests__/promiseBeforeAll.test.js
Expand Up @@ -15,7 +15,7 @@ describe('promise beforeAll', () => {
process.nextTick(resolve);
}).then(() => {
flag = 1;
})
}),
);

beforeAll(() => new Promise(resolve => setTimeout(resolve, 10)), 500);
Expand Down
2 changes: 1 addition & 1 deletion e2e/jasmine-async/__tests__/promiseBeforeEach.test.js
Expand Up @@ -13,7 +13,7 @@ describe('promise beforeEach', () => {
process.nextTick(resolve);
}).then(() => {
this.flag = 1;
})
}),
);

// passing tests
Expand Down
6 changes: 3 additions & 3 deletions e2e/jasmine-async/__tests__/promiseIt.test.js
Expand Up @@ -31,7 +31,7 @@ describe('promise it', () => {
new Promise(resolve => {
if (this.someContextValue !== 'value') {
throw new Error(
'expected this.someContextValue to be set: ' + this.someContextValue
'expected this.someContextValue to be set: ' + this.someContextValue,
);
}
resolve();
Expand Down Expand Up @@ -90,13 +90,13 @@ describe('promise it', () => {
it(
'succeeds if the test finishes in time',
() => new Promise(resolve => setTimeout(resolve, 10)),
250
250,
);

// failing tests
it(
'fails if a custom timeout is exceeded',
() => new Promise(resolve => setTimeout(resolve, 100)),
10
10,
);
});
2 changes: 1 addition & 1 deletion e2e/native-esm/__tests__/native-esm.test.js
Expand Up @@ -21,7 +21,7 @@ test('should have correct import.meta', () => {
url: expect.any(String),
});
expect(
import.meta.url.endsWith('/e2e/native-esm/__tests__/native-esm.test.js')
import.meta.url.endsWith('/e2e/native-esm/__tests__/native-esm.test.js'),
).toBe(true);
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/reset-modules/__tests__/resetModules.test.js
Expand Up @@ -12,7 +12,7 @@ global.testObject = new Proxy(
get: function getter(target, key) {
return key;
},
}
},
);
test('jest.resetModules should not error when _isMockFunction is defined but not boolean', () => {
jest.resetModules();
Expand Down
10 changes: 5 additions & 5 deletions e2e/resolve-with-paths/__tests__/resolveWithPaths.test.js
Expand Up @@ -10,19 +10,19 @@ import {resolve} from 'path';

test('finds a module relative to one of the given paths', () => {
expect(require.resolve('./mod.js', {paths: ['../dir']})).toEqual(
resolve(__dirname, '..', 'dir', 'mod.js')
resolve(__dirname, '..', 'dir', 'mod.js'),
);
});

test('finds a module without a leading "./" relative to one of the given paths', () => {
expect(require.resolve('mod.js', {paths: ['../dir']})).toEqual(
resolve(__dirname, '..', 'dir', 'mod.js')
resolve(__dirname, '..', 'dir', 'mod.js'),
);
});

test('finds a node_module above one of the given paths', () => {
expect(require.resolve('mod', {paths: ['../dir']})).toEqual(
resolve(__dirname, '..', 'node_modules', 'mod', 'index.js')
resolve(__dirname, '..', 'node_modules', 'mod', 'index.js'),
);
});

Expand All @@ -32,12 +32,12 @@ test('finds a native node module when paths are given', () => {

test('throws an error if the module cannot be found from given paths', () => {
expect(() => require.resolve('./mod.js', {paths: ['..']})).toThrowError(
"Cannot resolve module './mod.js' from paths ['..'] from "
"Cannot resolve module './mod.js' from paths ['..'] from ",
);
});

test('throws module not found error if the module cannot be found from given paths', () => {
expect(() => require.resolve('./mod.js', {paths: ['..']})).toThrow(
expect.objectContaining({code: 'MODULE_NOT_FOUND'})
expect.objectContaining({code: 'MODULE_NOT_FOUND'}),
);
});
6 changes: 3 additions & 3 deletions e2e/resolve/__tests__/resolve.test.js
Expand Up @@ -66,7 +66,7 @@ test('should resolve filename.json', () => {

test('should preserve identity for symlinks', () => {
expect(require('../../../packages/jest-resolve')).toBe(
require('jest-resolve')
require('jest-resolve'),
);
});

Expand Down Expand Up @@ -113,7 +113,7 @@ test('should throw module not found error if the module has dependencies that ca
Test7.js
__tests__/resolve.test.js\n
`,
})
}),
);
});

Expand All @@ -122,6 +122,6 @@ test('should throw module not found error if the module cannot be found', () =>
expect.objectContaining({
code: 'MODULE_NOT_FOUND',
message: "Cannot find module 'Test8' from 'resolve.test.js'",
})
}),
);
});
2 changes: 1 addition & 1 deletion e2e/snapshot/__tests__/snapshot.test.js
Expand Up @@ -30,7 +30,7 @@ describe('snapshot', () => {

it('cannot be used with .not', () => {
expect(() => expect('').not.toMatchSnapshot()).toThrow(
'Snapshot matchers cannot be used with not'
'Snapshot matchers cannot be used with not',
);
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/typescript-coverage/typescriptPreprocessor.js
Expand Up @@ -17,7 +17,7 @@ module.exports = {
module: tsc.ModuleKind.CommonJS,
},
path,
[]
[],
);
}
return src;
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/app.component.spec.ts
Expand Up @@ -8,7 +8,7 @@ const getTitleFn = jest.fn().mockReturnValue(title);
const dataServiceSpy = jest.fn().mockImplementation(
(): Partial<DataService> => ({
getTitle: getTitleFn,
})
}),
);

describe('AppComponent', () => {
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('AppComponent', () => {
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain(
`Welcome to ${title}!`
`Welcome to ${title}!`,
);
});
});
2 changes: 1 addition & 1 deletion examples/angular/setupJest.js
Expand Up @@ -14,5 +14,5 @@ const testingModule = require('@angular/platform-browser-dynamic/testing');

getTestBed().initTestEnvironment(
testingModule.BrowserDynamicTestingModule,
testingModule.platformBrowserDynamicTesting()
testingModule.platformBrowserDynamicTesting(),
);
2 changes: 1 addition & 1 deletion examples/async/__mocks__/request.js
Expand Up @@ -15,7 +15,7 @@ export default function request(url) {
? resolve(users[userID])
: reject({
error: 'User with ' + userID + ' not found.',
})
}),
);
});
}
2 changes: 1 addition & 1 deletion examples/async/__tests__/user.test.js
Expand Up @@ -45,7 +45,7 @@ test('tests error with promises', async () => {
return user.getUserName(2).catch(e =>
expect(e).toEqual({
error: 'User with 2 not found.',
})
}),
);
});

Expand Down