Skip to content

Commit 68dd53e

Browse files
committed
feat: make jest-circus default test runner
1 parent 2fa34c4 commit 68dd53e

File tree

28 files changed

+147
-157
lines changed

28 files changed

+147
-157
lines changed

.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

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

89
### Fixes

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

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

11711171
### `testRunner` [string]
11721172

1173-
Default: `jasmine2`
1173+
Default: `jest-circus/runner`
11741174

1175-
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.
1175+
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.
11761176

11771177
The test runner module must export a function with the following signature:
11781178

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__/circusConcurrentEach.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
import {skipSuiteOnJasmine} from '@jest/test-utils';
78
import {json as runWithJson} from '../runJest';
89

10+
skipSuiteOnJasmine();
11+
912
it('works with concurrent.each', () => {
10-
const {json} = runWithJson('circus-concurrent', [
11-
'concurrent-each.test.js',
12-
'--testRunner=jest-circus/runner',
13-
]);
13+
const {json} = runWithJson('circus-concurrent', ['concurrent-each.test.js']);
1414
expect(json.numTotalTests).toBe(4);
1515
expect(json.numPassedTests).toBe(2);
1616
expect(json.numFailedTests).toBe(0);
@@ -20,7 +20,6 @@ it('works with concurrent.each', () => {
2020
it('works with concurrent.only.each', () => {
2121
const {json} = runWithJson('circus-concurrent', [
2222
'concurrent-only-each.test.js',
23-
'--testRunner=jest-circus/runner',
2423
]);
2524
expect(json.numTotalTests).toBe(4);
2625
expect(json.numPassedTests).toBe(2);

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']);

e2e/__tests__/toMatchInlineSnapshotWithRetries.test.ts

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

88
import * as path from 'path';
9+
import {skipSuiteOnJasmine} from '@jest/test-utils';
910
import {cleanup, makeTemplate, writeFiles} from '../Utils';
1011
import runJest from '../runJest';
1112

@@ -15,6 +16,8 @@ const TESTS_DIR = path.resolve(DIR, '__tests__');
1516
beforeEach(() => cleanup(TESTS_DIR));
1617
afterAll(() => cleanup(TESTS_DIR));
1718

19+
skipSuiteOnJasmine();
20+
1821
test('works with a single snapshot', () => {
1922
const filename = 'basic-support.test.js';
2023
const template = makeTemplate(`
@@ -39,12 +42,7 @@ test('works with a single snapshot', () => {
3942
writeFiles(TESTS_DIR, {
4043
[filename]: template(['index', '2' /* retries */]),
4144
});
42-
const {stderr, exitCode} = runJest(DIR, [
43-
'-w=1',
44-
'--ci=false',
45-
'--testRunner=jest-circus/runner',
46-
filename,
47-
]);
45+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
4846
expect(stderr).toMatch('Received: 2');
4947
expect(stderr).toMatch('1 snapshot failed from 1 test suite.');
5048
expect(exitCode).toBe(1);
@@ -54,12 +52,7 @@ test('works with a single snapshot', () => {
5452
writeFiles(TESTS_DIR, {
5553
[filename]: template(['index', '4' /* retries */]),
5654
});
57-
const {stderr, exitCode} = runJest(DIR, [
58-
'-w=1',
59-
'--ci=false',
60-
'--testRunner=jest-circus/runner',
61-
filename,
62-
]);
55+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
6356
expect(stderr).toMatch('Snapshots: 1 passed, 1 total');
6457
expect(exitCode).toBe(0);
6558
}
@@ -113,12 +106,7 @@ test('works when multiple tests have snapshots but only one of them failed multi
113106
writeFiles(TESTS_DIR, {
114107
[filename]: template(['index', '2' /* retries */]),
115108
});
116-
const {stderr, exitCode} = runJest(DIR, [
117-
'-w=1',
118-
'--ci=false',
119-
'--testRunner=jest-circus/runner',
120-
filename,
121-
]);
109+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
122110
expect(stderr).toMatch('Snapshot name: `with retries snapshots 1`');
123111
expect(stderr).toMatch('Received: 2');
124112
expect(stderr).toMatch('1 snapshot failed from 1 test suite.');
@@ -129,12 +117,7 @@ test('works when multiple tests have snapshots but only one of them failed multi
129117
writeFiles(TESTS_DIR, {
130118
[filename]: template(['index', '4' /* retries */]),
131119
});
132-
const {stderr, exitCode} = runJest(DIR, [
133-
'-w=1',
134-
'--ci=false',
135-
'--testRunner=jest-circus/runner',
136-
filename,
137-
]);
120+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
138121
expect(stderr).toMatch('Snapshots: 1 passed, 1 total');
139122
expect(exitCode).toBe(0);
140123
}

0 commit comments

Comments
 (0)