Skip to content

Commit

Permalink
feat: support Jest 27 (#676)
Browse files Browse the repository at this point in the history
BREAKING CHANGE
- Node 10 won't work due to jsdom bug, see jestjs/jest#10957. If you have errors with node 10 related to `globalThis`, workaround for now is switching to node 12.
- Since default `testRunner` in Jest 27 is `jest-circus`, `async` test with `done` callback no longer works, see discussion at jestjs/jest#10529. If you want to have `async` test with `done` callback, please use `testRunner: 'jest-jasmine2'` in your jest config.
  • Loading branch information
ahnpnl committed Dec 18, 2020
1 parent 168cfda commit 1a6b10e
Show file tree
Hide file tree
Showing 19 changed files with 2,447 additions and 2,081 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

Expand Down
4 changes: 2 additions & 2 deletions e2e/test-app-v10-zone-v11/package.json
Expand Up @@ -5,7 +5,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "jest --no-cache",
"test": "jest --clearCache && jest",
"lint": "ng lint"
},
"private": true,
Expand All @@ -31,7 +31,7 @@
"@types/jquery": "^3.5.4",
"@types/node": "^12.19.3",
"codelyzer": "^6.0.1",
"jest": "^26.6.2",
"jest": "^27.0.0-next.2",
"ts-node": "~9.0.0",
"tslint": "~6.1.3",
"typescript": "~4.0.5"
Expand Down
1,051 changes: 570 additions & 481 deletions e2e/test-app-v10-zone-v11/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions e2e/test-app-v10/package.json
Expand Up @@ -5,7 +5,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "jest --no-cache",
"test": "jest --clearCache && jest",
"lint": "ng lint"
},
"private": true,
Expand All @@ -29,7 +29,7 @@
"@types/jest": "^26.0.15",
"@types/node": "^12.19.3",
"codelyzer": "^6.0.1",
"jest": "^26.6.2",
"jest": "^27.0.0-next.2",
"ng-packagr": "^10.1.0",
"ts-node": "~9.0.0",
"tslint": "~6.1.3",
Expand Down
1,011 changes: 565 additions & 446 deletions e2e/test-app-v10/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions e2e/test-app-v9/package.json
Expand Up @@ -5,7 +5,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "jest --no-cache",
"test": "jest --clearCache && jest",
"lint": "ng lint"
},
"private": true,
Expand All @@ -30,7 +30,7 @@
"@angular/language-service": "~9.1.12",
"@types/jest": "^26.0.15",
"@types/node": "^12.19.3",
"jest": "^26.6.2",
"jest": "^27.0.0-next.2",
"ts-node": "^9.0.0",
"typescript": "~3.8.3"
}
Expand Down
22 changes: 14 additions & 8 deletions e2e/test-app-v9/src/app/app.component.spec.ts
Expand Up @@ -84,14 +84,20 @@ describe('AppComponent', () => {
}, 100);
});

it('async with done should work', async done => {
let flag = false;
setTimeout(() => {
flag = true;
expect(flag).toBe(true);
done();
}, 100);
});
/*
* This test doesn't work with jest-circus `testRunner`. If you want to test async with done callback, please use
* testRunner `jest-jasmine2`.
*
* More information see discussion https://github.com/facebook/jest/issues/10529
*/
// it('async with done should not work with jest-circus', async done => {
// let flag = false;
// setTimeout(() => {
// flag = true;
// expect(flag).toBe(true);
// done();
// }, 100);
// });

it.each([[1, 2]])('it.each', (arg1, arg2) => {
expect(arg1).toBe(1);
Expand Down

0 comments on commit 1a6b10e

Please sign in to comment.