Skip to content

Commit 1519ceb

Browse files
committed
Merge branch 'main' into stanleyume-patch-1
2 parents 302decb + ac8ee61 commit 1519ceb

File tree

388 files changed

+405
-90034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

388 files changed

+405
-90034
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44

55
### Fixes
66

7+
- `[jest-core]` Fix typo in `scheduleAndRun` performance marker ([#14434](https://github.com/jestjs/jest/pull/14434))
8+
9+
### Chore & Maintenance
10+
11+
## 29.6.3
12+
713
- `[expect, @jest/expect-utils]` `ObjectContaining` support `sumbol` as key ([#14414](https://github.com/jestjs/jest/pull/14414))
814
- `[expect]` Remove `@types/node` from dependencies ([#14385](https://github.com/jestjs/jest/pull/14385))
915
- `[jest-core]` Use workers in watch mode by default to avoid crashes ([#14059](https://github.com/facebook/jest/pull/14059) & [#14085](https://github.com/facebook/jest/pull/14085)).
1016
- `[jest-reporters]` Update `istanbul-lib-instrument` dependency to v6. ([#14401](https://github.com/jestjs/jest/pull/14401))
17+
- `[jest-mock]` Revert [#13692](https://github.com/jestjs/jest/pull/13692) as it was a breaking change ([#14429](https://github.com/jestjs/jest/pull/14429))
18+
- `[jest-mock]` Revert [#13866](https://github.com/jestjs/jest/pull/13866) as it was a breaking change ([#14429](https://github.com/jestjs/jest/pull/14429))
19+
- `[jest-mock]` Revert [#13867](https://github.com/jestjs/jest/pull/13867) as it was a breaking change ([#14429](https://github.com/jestjs/jest/pull/14429))
20+
- `[@jest/reporters]` Marks Reporter's hooks as optional ([#14433](https://github.com/jestjs/jest/pull/14433))
21+
- `[jest-runtime]` Fix dynamic ESM import module bug when loaded module through `jest.isolateModulesAsync` ([#14397](https://github.com/jestjs/jest/pull/14397))
1122

1223
### Chore & Maintenance
1324

14-
### Performance
25+
- `[jest-changed-files, jest-circus, jest-console, @jest/core, @jest/runtime, @jest/transform]` Use `invariant` and `notEmpty` from `jest-util` rather than own internal ([#14366](https://github.com/jestjs/jest/pull/14366))
1526

1627
## 29.6.2
1728

docs/Configuration.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi
14011401

14021402
:::
14031403

1404-
Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)):
1404+
Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments:
14051405

14061406
```js title="custom-reporter.js"
14071407
class CustomReporter {
@@ -1430,6 +1430,12 @@ class CustomReporter {
14301430
module.exports = CustomReporter;
14311431
```
14321432

1433+
:::note
1434+
1435+
For the full list of hooks and argument types see the `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts).
1436+
1437+
:::
1438+
14331439
### `resetMocks` \[boolean]
14341440

14351441
Default: `false`

docs/MockFunctionAPI.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ Beware that `mockFn.mockClear()` will replace `mockFn.mock`, not just reset the
128128

129129
### `mockFn.mockReset()`
130130

131-
Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also removes any mocked return values or implementations.
132-
133-
This is useful when you want to completely reset a _mock_ back to its initial state.
131+
Does everything that [`mockFn.mockClear()`](#mockfnmockclear) does, and also replaces the mock implementation with an empty function, returning `undefined`.
134132

135133
The [`resetMocks`](configuration#resetmocks-boolean) configuration option is available to reset mocks automatically before each test.
136134

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports[`defining tests and hooks asynchronously throws 1`] = `
1616
14 | });
1717
15 | });
1818
19-
at eventHandler (../../packages/jest-circus/build/eventHandler.js:140:11)
19+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:141:11)
2020
at test (__tests__/asyncDefinition.test.js:12:5)
2121
2222
● Test suite failed to run
@@ -31,7 +31,7 @@ exports[`defining tests and hooks asynchronously throws 1`] = `
3131
15 | });
3232
16 |
3333
34-
at eventHandler (../../packages/jest-circus/build/eventHandler.js:103:11)
34+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:104:11)
3535
at afterAll (__tests__/asyncDefinition.test.js:13:5)
3636
3737
● Test suite failed to run
@@ -46,7 +46,7 @@ exports[`defining tests and hooks asynchronously throws 1`] = `
4646
20 | });
4747
21 |
4848
49-
at eventHandler (../../packages/jest-circus/build/eventHandler.js:140:11)
49+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:141:11)
5050
at test (__tests__/asyncDefinition.test.js:18:3)
5151
5252
● Test suite failed to run
@@ -60,6 +60,6 @@ exports[`defining tests and hooks asynchronously throws 1`] = `
6060
20 | });
6161
21 |
6262
63-
at eventHandler (../../packages/jest-circus/build/eventHandler.js:103:11)
63+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:104:11)
6464
at afterAll (__tests__/asyncDefinition.test.js:19:3)"
6565
`;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`runs test with isolate modules async import 1`] = `
4+
"Test Suites: 1 passed, 1 total
5+
Tests: 1 passed, 1 total
6+
Snapshots: 0 total
7+
Time: <<REPLACED>>
8+
Ran all test suites."
9+
`;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import {extractSummary} from '../Utils';
9+
import runJest from '../runJest';
10+
11+
test('runs test with isolate modules async import', () => {
12+
const {exitCode, stderr} = runJest('isolate-modules-async', [], {
13+
nodeOptions: '--experimental-vm-modules --no-warnings',
14+
});
15+
16+
const {summary} = extractSummary(stderr);
17+
18+
expect(summary).toMatchSnapshot();
19+
expect(exitCode).toBe(0);
20+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
import {jest} from '@jest/globals';
8+
9+
test('should have a fresh module state in each isolateModulesAsync context', async () => {
10+
await jest.isolateModulesAsync(async () => {
11+
const {getState, incState} = await import('../main.js');
12+
expect(getState()).toBe(0);
13+
incState();
14+
expect(getState()).toBe(1);
15+
});
16+
await jest.isolateModulesAsync(async () => {
17+
const {getState, incState} = await import('../main.js');
18+
expect(getState()).toBe(0);
19+
incState();
20+
expect(getState()).toBe(1);
21+
});
22+
});

e2e/isolate-modules-async/main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
let myState = 0;
8+
9+
export function incState() {
10+
myState += 1;
11+
}
12+
13+
export function getState() {
14+
return myState;
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "isolate-modules-async",
3+
"type": "module",
4+
"jest": {
5+
"transform": {},
6+
"testEnvironment": "node"
7+
}
8+
}

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"syncWorkspaceLock": true
99
}
1010
},
11-
"version": "29.6.2"
11+
"version": "29.6.3"
1212
}

0 commit comments

Comments
 (0)