Skip to content

Commit 5f6f2ec

Browse files
authored
feat: make jest-circus default test runner (#10686)
1 parent e442dec commit 5f6f2ec

27 files changed

Lines changed: 135 additions & 111 deletions

File tree

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- store_test_results:
2828
path: reports/junit
2929

30-
test-jest-circus:
30+
test-jest-jasmine:
3131
working_directory: ~/jest
3232
executor: node/default
3333
steps:
@@ -37,7 +37,7 @@ jobs:
3737
install-npm: false
3838
- node/install-packages: *install
3939
- run:
40-
command: JEST_CIRCUS=1 yarn test-ci-partial && JEST_CIRCUS=1 yarn test-leak
40+
command: JEST_JASMINE=1 yarn test-ci-partial && JEST_JASMINE=1 yarn test-leak
4141
- store_test_results:
4242
path: reports/junit
4343

@@ -106,6 +106,6 @@ workflows:
106106
- test-node-12
107107
- test-node-14
108108
- test-node-15 # current
109-
- test-jest-circus
109+
- test-jest-jasmine
110110
- test-or-deploy-website:
111111
filters: *filter-ignore-gh-pages

.github/workflows/nodejs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ jobs:
9191
env:
9292
CI: true
9393

94-
test-circus:
95-
name: Node LTS on ${{ matrix.os }} using jest-circus
94+
test-jasmine:
95+
name: Node LTS on ${{ matrix.os }} using jest-jasmine2
9696
strategy:
9797
fail-fast: false
9898
matrix:
@@ -127,7 +127,7 @@ jobs:
127127
- name: Get number of CPU cores
128128
id: cpu-cores
129129
uses: SimenB/github-actions-cpu-cores@v1
130-
- name: run tests using jest-circus
131-
run: yarn jest-circus-ci --max-workers ${{ steps.cpu-cores.outputs.count }}
130+
- name: run tests using jest-jasmine
131+
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }}
132132
env:
133133
CI: true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Features
44

55
- `[jest-config]` [**BREAKING**] Default to Node testing environment instead of browser (JSDOM) ([#9874](https://github.com/facebook/jest/pull/9874))
6+
- `[jest-config]` [**BREAKING**] Use `jest-circus` as default test runner ([#10686](https://github.com/facebook/jest/pull/10686))
67
- `[jest-runner]` [**BREAKING**] set exit code to 1 if test logs after teardown ([#10728](https://github.com/facebook/jest/pull/10728))
78
- `[jest-snapshot]`: [**BREAKING**] Make prettier optional for inline snapshots - fall back to string replacement ([#7792](https://github.com/facebook/jest/pull/7792))
89
- `[jest-repl, jest-runner]` [**BREAKING**] Run transforms over environment ([#8751](https://github.com/facebook/jest/pull/8751))

docs/CLI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ test('some test', () => {
208208
});
209209
```
210210

211-
_Note: This option is only supported using `jest-circus`._
211+
_Note: This option is only supported using the default `jest-circus`. test runner_
212212

213213
### `--json`
214214

docs/Configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ test('some test', () => {
501501
});
502502
```
503503

504-
_Note: This option is only supported using `jest-circus`._
504+
_Note: This option is only supported using the default `jest-circus`. test runner_
505505

506506
### `maxConcurrency` [number]
507507

@@ -1181,9 +1181,9 @@ This option allows the use of a custom results processor. This processor must be
11811181

11821182
### `testRunner` [string]
11831183

1184-
Default: `jasmine2`
1184+
Default: `jest-circus/runner`
11851185

1186-
This option allows the use of a custom test runner. The default is jasmine2. A custom test runner can be provided by specifying a path to a test runner implementation.
1186+
This option allows the use of a custom test runner. The default is `jest-circus`. A custom test runner can be provided by specifying a path to a test runner implementation.
11871187

11881188
The test runner module must export a function with the following signature:
11891189

docs/JestObjectAPI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ jest.setTimeout(1000); // 1 second
672672

673673
### `jest.retryTimes()`
674674

675-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. This only works with [jest-circus](https://github.com/facebook/jest/tree/master/packages/jest-circus)!
675+
Runs failed tests n-times until they pass or until the max number of retries is exhausted. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/master/packages/jest-circus) runner!
676676

677677
Example in a test:
678678

e2e/__tests__/__snapshots__/showConfig.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
6262
"/node_modules/"
6363
],
6464
"testRegex": [],
65-
"testRunner": "<<REPLACED_JEST_PACKAGES_DIR>>/jest-jasmine2/build/index.js",
65+
"testRunner": "<<REPLACED_JEST_PACKAGES_DIR>>/jest-circus/runner.js",
6666
"testURL": "http://localhost",
6767
"timers": "real",
6868
"transform": [

e2e/__tests__/failureDetailsProperty.test.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {isJestCircusRun} from '@jest/test-utils';
8+
import {isJestJasmineRun} from '@jest/test-utils';
99
import runJest from '../runJest';
1010

1111
const removeStackTraces = (stdout: string) =>
@@ -24,59 +24,7 @@ test('that the failureDetails property is set', () => {
2424

2525
const output = JSON.parse(removeStackTraces(stdout));
2626

27-
if (isJestCircusRun()) {
28-
expect(output).toMatchInlineSnapshot(`
29-
Array [
30-
Array [
31-
Object {
32-
"matcherResult": Object {
33-
"actual": true,
34-
"expected": false,
35-
"name": "toBe",
36-
"pass": false,
37-
},
38-
},
39-
],
40-
Array [
41-
Object {
42-
"matcherResult": Object {
43-
"actual": true,
44-
"expected": false,
45-
"name": "toBe",
46-
"pass": false,
47-
},
48-
},
49-
],
50-
Array [
51-
Object {
52-
"matcherResult": Object {
53-
"actual": "Object {
54-
\\"p1\\": \\"hello\\",
55-
\\"p2\\": \\"world\\",
56-
}",
57-
"expected": "Object {
58-
\\"p1\\": \\"hello\\",
59-
\\"p2\\": \\"sunshine\\",
60-
}",
61-
"name": "toMatchInlineSnapshot",
62-
"pass": false,
63-
},
64-
},
65-
],
66-
Array [
67-
Object {},
68-
],
69-
Array [
70-
Object {
71-
"message": "expect(received).rejects.toThrowError()
72-
73-
Received promise resolved instead of rejected
74-
Resolved to value: 1",
75-
},
76-
],
77-
]
78-
`);
79-
} else {
27+
if (isJestJasmineRun()) {
8028
expect(output).toMatchInlineSnapshot(`
8129
Array [
8230
Array [
@@ -213,5 +161,57 @@ test('that the failureDetails property is set', () => {
213161
],
214162
]
215163
`);
164+
} else {
165+
expect(output).toMatchInlineSnapshot(`
166+
Array [
167+
Array [
168+
Object {
169+
"matcherResult": Object {
170+
"actual": true,
171+
"expected": false,
172+
"name": "toBe",
173+
"pass": false,
174+
},
175+
},
176+
],
177+
Array [
178+
Object {
179+
"matcherResult": Object {
180+
"actual": true,
181+
"expected": false,
182+
"name": "toBe",
183+
"pass": false,
184+
},
185+
},
186+
],
187+
Array [
188+
Object {
189+
"matcherResult": Object {
190+
"actual": "Object {
191+
\\"p1\\": \\"hello\\",
192+
\\"p2\\": \\"world\\",
193+
}",
194+
"expected": "Object {
195+
\\"p1\\": \\"hello\\",
196+
\\"p2\\": \\"sunshine\\",
197+
}",
198+
"name": "toMatchInlineSnapshot",
199+
"pass": false,
200+
},
201+
},
202+
],
203+
Array [
204+
Object {},
205+
],
206+
Array [
207+
Object {
208+
"message": "expect(received).rejects.toThrowError()
209+
210+
Received promise resolved instead of rejected
211+
Resolved to value: 1",
212+
},
213+
],
214+
]
215+
`);
216216
}
217217
});

e2e/__tests__/locationInResults.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {isJestCircusRun} from '@jest/test-utils';
8+
import {isJestJasmineRun} from '@jest/test-utils';
99
import {json as runWithJson} from '../runJest';
1010

1111
it('defaults to null for location', () => {
@@ -45,39 +45,39 @@ it('adds correct location info when provided with flag', () => {
4545
});
4646

4747
expect(assertions[3].location).toEqual({
48-
column: isJestCircusRun() ? 1 : 22,
48+
column: isJestJasmineRun() ? 22 : 1,
4949
line: 24,
5050
});
5151

5252
expect(assertions[4].location).toEqual({
53-
column: isJestCircusRun() ? 1 : 22,
53+
column: isJestJasmineRun() ? 22 : 1,
5454
line: 24,
5555
});
5656

5757
// Technically the column should be 3, but callsites is not correct.
5858
// jest-circus uses stack-utils + asyncErrors which resolves this.
5959
expect(assertions[5].location).toEqual({
60-
column: isJestCircusRun() ? 3 : 2,
60+
column: isJestJasmineRun() ? 2 : 3,
6161
line: 29,
6262
});
6363

6464
expect(assertions[6].location).toEqual({
65-
column: isJestCircusRun() ? 3 : 2,
65+
column: isJestJasmineRun() ? 2 : 3,
6666
line: 33,
6767
});
6868

6969
expect(assertions[7].location).toEqual({
70-
column: isJestCircusRun() ? 3 : 2,
70+
column: isJestJasmineRun() ? 2 : 3,
7171
line: 37,
7272
});
7373

7474
expect(assertions[8].location).toEqual({
75-
column: isJestCircusRun() ? 3 : 24,
75+
column: isJestJasmineRun() ? 24 : 3,
7676
line: 41,
7777
});
7878

7979
expect(assertions[9].location).toEqual({
80-
column: isJestCircusRun() ? 3 : 24,
80+
column: isJestJasmineRun() ? 24 : 3,
8181
line: 41,
8282
});
8383
});

e2e/__tests__/nestedTestDefinitions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import {wrap} from 'jest-snapshot-serializer-raw';
9-
import {isJestCircusRun} from '@jest/test-utils';
9+
import {isJestJasmineRun} from '@jest/test-utils';
1010
import {extractSummary} from '../Utils';
1111
import runJest from '../runJest';
1212

@@ -42,7 +42,7 @@ test('print correct error message with nested test definitions inside describe',
4242
expect(cleanupRunnerStack(summary.rest)).toMatchSnapshot();
4343
});
4444

45-
(isJestCircusRun() ? test : test.skip)(
45+
(isJestJasmineRun() ? test.skip : test)(
4646
'print correct message when nesting describe inside it',
4747
() => {
4848
const result = runJest('nested-test-definitions', ['nestedDescribeInTest']);
@@ -55,7 +55,7 @@ test('print correct error message with nested test definitions inside describe',
5555
},
5656
);
5757

58-
(isJestCircusRun() ? test : test.skip)(
58+
(isJestJasmineRun() ? test.skip : test)(
5959
'print correct message when nesting a hook inside it',
6060
() => {
6161
const result = runJest('nested-test-definitions', ['nestedHookInTest']);

0 commit comments

Comments
 (0)