Skip to content

Commit 8a58fde

Browse files
committed
Rename some options before releasing Jest 30.
1 parent ce14203 commit 8a58fde

File tree

35 files changed

+73
-78
lines changed

35 files changed

+73
-78
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Features
44

5+
- `[*]` Renamed `globalsCleanupMode` to `globalsCleanup` and `--waitNextEventLoopTurnForUnhandledRejectionEvents` to `--waitForUnhandledRejections`
56
- `[expect]` Add `ArrayOf` asymmetric matcher for validating array elements. ([#15567](https://github.com/jestjs/jest/pull/15567))
67
- `[babel-jest]` Add option `excludeJestPreset` to allow opting out of `babel-preset-jest` ([#15164](https://github.com/jestjs/jest/pull/15164))
78
- `[expect]` Revert [#15038](https://github.com/jestjs/jest/pull/15038) to fix `expect(fn).toHaveBeenCalledWith(expect.objectContaining(...))` when there are multiple calls ([#15508](https://github.com/jestjs/jest/pull/15508))

docs/CLI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ Display individual test results with the test suite hierarchy.
524524

525525
Alias: `-v`. Print the version and exit.
526526

527-
### `--waitNextEventLoopTurnForUnhandledRejectionEvents`
527+
### `--waitForUnhandledRejections`
528528

529529
Gives one event loop turn to handle `rejectionHandled`, `uncaughtException` or `unhandledRejection`.
530530

docs/Configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ Default: `false` or `true` if there is only one test file to run
24132413

24142414
Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution.
24152415

2416-
### `waitNextEventLoopTurnForUnhandledRejectionEvents` \[boolean]
2416+
### `waitForUnhandledRejections` \[boolean]
24172417

24182418
Gives one event loop turn to handle `rejectionHandled`, `uncaughtException` or `unhandledRejection`.
24192419

docs/UpgradingToJest30.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Jest includes a fix to properly handle promises that are rejected and later caug
116116

117117
:::info
118118

119-
You should see fewer false positives for unhandled promise rejections. Tests that previously failed due to async handled rejections should now pass. However, this change can slightly slow down test completion, especially in tests that intentionally reject promises. To mitigate performance impact, a new configuration flag `waitNextEventLoopTurnForUnhandledRejectionEvents` was introduced. This flag, when disabled, can restore the previous behavior (not waiting) if absolutely needed. Most users should not need to change this – the default now favors correctness by preventing false failures.
119+
You should see fewer false positives for unhandled promise rejections. Tests that previously failed due to async handled rejections should now pass. However, this change can slightly slow down test completion, especially in tests that intentionally reject promises. To mitigate performance impact, a new configuration flag `waitForUnhandledRejections` was introduced. This flag, when disabled, can restore the previous behavior (not waiting) if absolutely needed. Most users should not need to change this – the default now favors correctness by preventing false failures.
120120

121121
:::
122122

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3-
exports[`prints useful error for environment methods after test is done w/ \`waitNextEventLoopTurnForUnhandledRejectionEvents\` 1`] = `
3+
exports[`prints useful error for environment methods after test is done w/ \`waitForUnhandledRejections\` 1`] = `
44
" ReferenceError: You are trying to access a property or method of the Jest environment outside of the scope of the test code.
55
66
9 | test('access environment methods after done', () => {
@@ -12,7 +12,7 @@ exports[`prints useful error for environment methods after test is done w/ \`wai
1212
14 |"
1313
`;
1414

15-
exports[`prints useful error for environment methods after test is done w/o \`waitNextEventLoopTurnForUnhandledRejectionEvents\` 1`] = `
15+
exports[`prints useful error for environment methods after test is done w/o \`waitForUnhandledRejections\` 1`] = `
1616
"ReferenceError: You are trying to access a property or method of the Jest environment after it has been torn down. From __tests__/afterTeardown.test.js.
1717
1818
9 | test('access environment methods after done', () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3-
exports[`prints useful error for requires after test is done w/ \`waitNextEventLoopTurnForUnhandledRejectionEvents\` 1`] = `
3+
exports[`prints useful error for requires after test is done w/ \`waitForUnhandledRejections\` 1`] = `
44
" ReferenceError: You are trying to \`import\` a file outside of the scope of the test code.
55
66
9 | test('require after done', () => {
@@ -12,7 +12,7 @@ exports[`prints useful error for requires after test is done w/ \`waitNextEventL
1212
14 | }, 0);"
1313
`;
1414
15-
exports[`prints useful error for requires after test is done w/o \`waitNextEventLoopTurnForUnhandledRejectionEvents\` 1`] = `
15+
exports[`prints useful error for requires after test is done w/o \`waitForUnhandledRejections\` 1`] = `
1616
"ReferenceError: You are trying to \`import\` a file after the Jest environment has been torn down. From __tests__/lateRequire.test.js.
1717
1818
9 | test('require after done', () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
9797
"/node_modules/",
9898
"<<REPLACED_PNP_PATH>>"
9999
],
100-
"waitNextEventLoopTurnForUnhandledRejectionEvents": false,
100+
"waitForUnhandledRejections": false,
101101
"watchPathIgnorePatterns": []
102102
}
103103
],
@@ -150,7 +150,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
150150
"testSequencer": "<<REPLACED_JEST_PACKAGES_DIR>>/jest-test-sequencer/build/index.js",
151151
"updateSnapshot": "none",
152152
"useStderr": false,
153-
"waitNextEventLoopTurnForUnhandledRejectionEvents": false,
153+
"waitForUnhandledRejections": false,
154154
"watch": false,
155155
"watchAll": false,
156156
"watchman": true,

e2e/__tests__/environmentAfterTeardown.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import runJest from '../runJest';
1010

1111
skipSuiteOnJasmine();
1212

13-
test('prints useful error for environment methods after test is done w/o `waitNextEventLoopTurnForUnhandledRejectionEvents`', () => {
13+
test('prints useful error for environment methods after test is done w/o `waitForUnhandledRejections`', () => {
1414
const {stderr} = runJest('environment-after-teardown');
1515
const interestingLines = stderr.split('\n').slice(9, 18).join('\n');
1616

@@ -20,9 +20,9 @@ test('prints useful error for environment methods after test is done w/o `waitNe
2020
);
2121
});
2222

23-
test('prints useful error for environment methods after test is done w/ `waitNextEventLoopTurnForUnhandledRejectionEvents`', () => {
23+
test('prints useful error for environment methods after test is done w/ `waitForUnhandledRejections`', () => {
2424
const {stderr} = runJest('environment-after-teardown', [
25-
'--waitNextEventLoopTurnForUnhandledRejectionEvents',
25+
'--waitForUnhandledRejections',
2626
]);
2727
const interestingLines = stderr.split('\n').slice(5, 14).join('\n');
2828

e2e/__tests__/environmentAfterTeardownJasmine.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ skipSuiteOnJestCircus();
1313
test.each`
1414
jestArgs
1515
${[]}
16-
${['--waitNextEventLoopTurnForUnhandledRejectionEvents']}
16+
${['--waitForUnhandledRejections']}
1717
`(
1818
'prints useful error for environment methods after test is done',
1919
({jestArgs}) => {

e2e/__tests__/fakeTimersLegacy.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ describe('requestAnimationFrame', () => {
3939
});
4040

4141
describe('setImmediate', () => {
42-
test('fakes setImmediate w/o `waitNextEventLoopTurnForUnhandledRejectionEvents`', () => {
42+
test('fakes setImmediate w/o `waitForUnhandledRejections`', () => {
4343
const result = runJest('fake-timers-legacy/set-immediate');
4444

4545
expect(result.stderr).toMatch('setImmediate test');
4646
expect(result.exitCode).toBe(0);
4747
});
4848

49-
test('fakes setImmediate w/ `waitNextEventLoopTurnForUnhandledRejectionEvents`', () => {
49+
test('fakes setImmediate w/ `waitForUnhandledRejections`', () => {
5050
// Jasmine runner does not handle unhandled promise rejections that are causing the test to fail in Jest circus
5151
const expectedExitCode = isJestJasmineRun() ? 0 : 1;
5252

5353
const result = runJest('fake-timers-legacy/set-immediate', [
54-
'--waitNextEventLoopTurnForUnhandledRejectionEvents',
54+
'--waitForUnhandledRejections',
5555
]);
5656

5757
expect(result.stderr).toMatch('setImmediate test');

0 commit comments

Comments
 (0)