Skip to content

Commit

Permalink
chore: add node 12 to CI (#8411)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 22, 2019
1 parent 6d91d7c commit ff050fc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ jobs:
- store_test_results:
path: reports/junit

test-node-11:
test-node-12:
working_directory: ~/jest
docker:
- image: circleci/node:11
- image: circleci/node:12
steps:
- checkout
- restore-cache: *restore-cache
Expand Down Expand Up @@ -120,8 +120,8 @@ workflows:
- lint-and-typecheck
- test-node-8
- test-node-10
- test-node-12 # current
- test-jest-circus
- test-node-11 # current
- test-browser
- test-or-deploy-website:
filters: *filter-ignore-gh-pages
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Chore & Maintenance

- `[*]` [**BREAKING**] Drop support for Node 6 ([#8455](https://github.com/facebook/jest/pull/8455))
- `[*]` Add Node 12 to CI ([#8411](https://github.com/facebook/jest/pull/8411))
- `[docs]` Fix broken link pointing to legacy JS file in "Snapshot Testing".
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM from v11 to v15 ([#8851](https://github.com/facebook/jest/pull/8851))

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/errorOnDeprecated.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FAIL __tests__/defaultTimeoutInterval.test.js
12 | });
13 |
at Object.<anonymous>.test (__tests__/defaultTimeoutInterval.test.js:10:3)
at Object.<anonymous> (__tests__/defaultTimeoutInterval.test.js:10:3)
`;
exports[`fail.test.js errors in errorOnDeprecated mode 1`] = `
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/failures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ FAIL __tests__/duringTests.test.js
40 |
41 | test('done(non-error)', done => {
at Object.<anonymous>.done (__tests__/duringTests.test.js:38:8)
at Object.<anonymous> (__tests__/duringTests.test.js:38:8)
● done(non-error)
Expand Down
19 changes: 18 additions & 1 deletion e2e/__tests__/errorOnDeprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,31 @@ const SHOULD_NOT_PASS_IN_JEST = new Set([
'spyOnProperty.test.js',
]);

const nodeMajorVersion = Number(process.versions.node.split('.')[0]);

testFiles.forEach(testFile => {
test(`${testFile} errors in errorOnDeprecated mode`, () => {
const result = runJest('error-on-deprecated', [
testFile,
'--errorOnDeprecated',
]);
expect(result.status).toBe(1);
const {rest} = extractSummary(result.stderr);
let {rest} = extractSummary(result.stderr);

if (
nodeMajorVersion < 12 &&
testFile === 'defaultTimeoutInterval.test.js'
) {
const lineEntry = '(__tests__/defaultTimeoutInterval.test.js:10:3)';

expect(rest).toContain(`at Object.<anonymous>.test ${lineEntry}`);

rest = rest.replace(
`at Object.<anonymous>.test ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}

expect(wrap(rest)).toMatchSnapshot();
});
});
Expand Down
19 changes: 15 additions & 4 deletions e2e/__tests__/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function cleanStderr(stderr: string) {
.replace(new RegExp('Failed: Object {', 'g'), 'thrown: Object {');
}

const nodeMajorVersion = Number(process.versions.node.split('.')[0]);

beforeAll(() => {
run('yarn', dir);
});
Expand All @@ -36,17 +38,28 @@ test('not throwing Error objects', () => {
stderr = runJest(dir, ['assertionCount.test.js']).stderr;
expect(wrap(cleanStderr(stderr))).toMatchSnapshot();
stderr = runJest(dir, ['duringTests.test.js']).stderr;

if (nodeMajorVersion < 12) {
const lineEntry = '(__tests__/duringTests.test.js:38:8)';

expect(stderr).toContain(`at Object.<anonymous>.done ${lineEntry}`);

stderr = stderr.replace(
`at Object.<anonymous>.done ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}

expect(wrap(cleanStderr(stderr))).toMatchSnapshot();
});

test('works with node assert', () => {
const nodeMajorVersion = Number(process.versions.node.split('.')[0]);
const {stderr} = runJest(dir, ['assertionError.test.js']);
let summary = normalizeDots(cleanStderr(stderr));

// Node 9 started to include the error for `doesNotThrow`
// https://github.com/nodejs/node/pull/12167
if (nodeMajorVersion >= 9) {
if (nodeMajorVersion >= 10) {
expect(summary).toContain(`
assert.doesNotThrow(function)
Expand Down Expand Up @@ -91,9 +104,7 @@ test('works with node assert', () => {
expect(summary).toContain(specificErrorMessage);
summary = summary.replace(specificErrorMessage, commonErrorMessage);
}
}

if (nodeMajorVersion >= 10) {
const ifErrorMessage = `
assert.ifError(received, expected)
Expand Down

0 comments on commit ff050fc

Please sign in to comment.