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: test on node 12 #8411

Merged
merged 2 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

- `[expect]` Display expectedDiff more carefully in toBeCloseTo ([#8389](https://github.com/facebook/jest/pull/8389))
- `[jest-fake-timers]` `getTimerCount` will not include cancelled immediates ([#8764](https://github.com/facebook/jest/pull/8764))
- `[jest-leak-detector]` [**BREAKING**] Use `weak-napi` instead of `weak` package ([#8686](https://github.com/facebook/jest/pull/8686))

### 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))
- `[jest-leak-detector]` [**BREAKING**] Use `weak-napi` instead of `weak` package ([#8686](https://github.com/facebook/jest/pull/8686))

### Performance

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