Skip to content

Commit a1a1e19

Browse files
authored
Merge branch 'facebook:main' into pass-jest-diff-options-to-fix-A11Y-issues#12576
2 parents 0c53a12 + 6e5b1d6 commit a1a1e19

File tree

155 files changed

+13845
-1175
lines changed

Some content is hidden

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

155 files changed

+13845
-1175
lines changed

.github/workflows/nodejs.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636

3737
steps:
3838
- uses: actions/checkout@v3
39+
with:
40+
persist-credentials: false
3941
- uses: actions/setup-node@v3
4042
with:
4143
node-version: lts/*
@@ -64,6 +66,8 @@ jobs:
6466

6567
steps:
6668
- uses: actions/checkout@v3
69+
with:
70+
persist-credentials: false
6771
- uses: actions/setup-node@v3
6872
with:
6973
node-version: lts/*
@@ -87,6 +91,8 @@ jobs:
8791
needs: prepare-yarn-cache-ubuntu
8892
steps:
8993
- uses: actions/checkout@v3
94+
with:
95+
persist-credentials: false
9096
- uses: actions/setup-node@v3
9197
with:
9298
node-version: lts/*
@@ -119,6 +125,8 @@ jobs:
119125

120126
steps:
121127
- uses: actions/checkout@v3
128+
with:
129+
persist-credentials: false
122130
- name: Use Node.js LTS
123131
uses: actions/setup-node@v3
124132
with:
@@ -142,6 +150,8 @@ jobs:
142150

143151
steps:
144152
- uses: actions/checkout@v3
153+
with:
154+
persist-credentials: false
145155
- name: Use Node.js LTS
146156
uses: actions/setup-node@v3
147157
with:

.github/workflows/prepare-cache.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17+
with:
18+
persist-credentials: false
1719

1820
- uses: actions/setup-node@v3
1921
with:

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v3
22+
with:
23+
persist-credentials: false
2224
- name: Use Node.js ${{ matrix.node-version }}
2325
uses: actions/setup-node@v3
2426
with:
@@ -44,6 +46,8 @@ jobs:
4446

4547
steps:
4648
- uses: actions/checkout@v3
49+
with:
50+
persist-credentials: false
4751
- name: Use Node.js LTS
4852
uses: actions/setup-node@v3
4953
with:

CHANGELOG.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,38 @@
66

77
### Fixes
88

9+
### Chore & Maintenance
10+
11+
- `[@jest/fake-timers]` Update `@sinonjs/fake-timers` ([#13612](https://github.com/facebook/jest/pull/13612))
12+
13+
### Performance
14+
15+
## 29.3.1
16+
17+
### Fixes
18+
19+
- `[jest-config]` Do not warn about `preset` in `ProjectConfig` ([#13583](https://github.com/facebook/jest/pull/13583))
20+
21+
### Performance
22+
23+
- `[jest-transform]` Defer creation of cache directory ([#13420](https://github.com/facebook/jest/pull/13420))
24+
25+
## 29.3.0
26+
27+
### Features
28+
29+
- `[jest-runtime]` Support WebAssembly (Wasm) imports in ESM modules ([#13505](https://github.com/facebook/jest/pull/13505))
30+
31+
### Fixes
32+
33+
- `[jest-config]` Add config validation for `projects` option ([#13565](https://github.com/facebook/jest/pull/13565))
934
- `[jest-mock]` Treat cjs modules as objects so they can be mocked ([#13513](https://github.com/facebook/jest/pull/13513))
35+
- `[jest-worker]` Throw an error instead of hanging when jest workers terminate unexpectedly ([#13566](https://github.com/facebook/jest/pull/13566))
1036

1137
### Chore & Maintenance
1238

1339
- `[@jest/transform]` Update `convert-source-map` ([#13509](https://github.com/facebook/jest/pull/13509))
14-
15-
### Performance
40+
- `[docs]` Mention `toStrictEqual` in UsingMatchers docs. ([#13560](https://github.com/facebook/jest/pull/13560))
1641

1742
## 29.2.2
1843

docs/CodeTransformation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ You can write your own transformer. The API of a transformer is as follows:
3636
interface TransformOptions<TransformerConfig = unknown> {
3737
supportsDynamicImport: boolean;
3838
supportsExportNamespaceFrom: boolean;
39+
/**
40+
* The value is:
41+
* - `false` if Jest runs without Node ESM flag `--experimental-vm-modules`
42+
* - `true` if the file extension is defined in [extensionsToTreatAsEsm](Configuration.md#extensionstotreatasesm-arraystring)
43+
* and Jest runs with Node ESM flag `--experimental-vm-modules`
44+
*
45+
* See more at https://jestjs.io/docs/next/ecmascript-modules
46+
*/
3947
supportsStaticESM: boolean;
4048
supportsTopLevelAwait: boolean;
4149
instrument: boolean;

docs/ECMAScriptModules.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ With the warnings out of the way, this is how you activate ESM support in your t
2222

2323
If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp).
2424

25+
If your codebase includes ESM imports from `*.wasm` files, you do _not_ need to pass `--experimental-wasm-modules` to `node`. Current implementation of WebAssembly imports in Jest relies on experimental VM modules, however, this may change in the future.
26+
2527
1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `.mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details.
2628
1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring).
2729

docs/GettingStarted.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Jest can be used in projects that use [webpack](https://webpack.js.org/) to mana
124124

125125
### Using Vite
126126

127-
Jest can be used in projects that use [vite](https://vitejs.dev/) to serves source code over native ESM to provide some frontend tooling, vite is an opinionated tool and does offer some out-of-the box workflows. Jest is not fully supported by vite due to how the [plugin system](https://github.com/vitejs/vite/issues/1955#issuecomment-776009094) from vite works, but there is some working examples for first-class jest integration using the `vite-jest`, since this is not fully supported, you might as well read the [limitation of the `vite-jest`](https://github.com/sodatea/vite-jest/tree/main/packages/vite-jest#limitations-and-differences-with-commonjs-tests). Refer to the [vite guide](https://vitejs.dev/guide/) to get started. Alternatively you can use [vitest](https://github.com/vitest-dev/vitest).
127+
Jest can be used in projects that use [vite](https://vitejs.dev/) to serve source code over native ESM to provide some frontend tooling, vite is an opinionated tool and does offer some out-of-the box workflows. Jest is not fully supported by vite due to how the [plugin system](https://github.com/vitejs/vite/issues/1955#issuecomment-776009094) from vite works, but there are some working examples for first-class jest integration using `vite-jest`, since this is not fully supported, you might as well read the [limitation of the `vite-jest`](https://github.com/sodatea/vite-jest/tree/main/packages/vite-jest#limitations-and-differences-with-commonjs-tests). Refer to the [vite guide](https://vitejs.dev/guide/) to get started. Alternatively you can use [vitest](https://github.com/vitest-dev/vitest).
128128

129129
### Using Parcel
130130

@@ -168,7 +168,13 @@ In order for Jest to transpile TypeScript with `ts-jest`, you may also need to c
168168

169169
There are two ways to have [Jest global APIs](GlobalAPI.md) typed for test files written in TypeScript.
170170

171-
You can use type definitions which ships with Jest and will update each time you update Jest. Simply import the APIs from `@jest/globals` package:
171+
You can use type definitions which ships with Jest and will update each time you update Jest. Install the `@jest/globals` package:
172+
173+
```bash npm2yarn
174+
npm install --save-dev @jest/globals
175+
```
176+
177+
And import the APIs from it:
172178

173179
```ts title="sum.test.ts"
174180
import {describe, expect, test} from '@jest/globals';

docs/GlobalAPI.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ test.todo('add should be associative');
973973

974974
## TypeScript Usage
975975

976+
<TypeScriptExamplesNote />
977+
976978
### `.each`
977979

978980
The `.each` modifier offers few different ways to define a table of the test cases. Some of the APIs have caveats related with the type inference of the arguments which are passed to `describe` or `test` callback functions. Let's take a look at each of them.

docs/MockFunctionAPI.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ test('async test', async () => {
517517

518518
## TypeScript Usage
519519

520-
:::tip
521-
522-
Please consult the [Getting Started](GettingStarted.md#using-typescript) guide for details on how to setup Jest with TypeScript.
523-
524-
:::
520+
<TypeScriptExamplesNote />
525521

526522
### `jest.fn(implementation?)`
527523

docs/UsingMatchers.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('two plus two is four', () => {
1717

1818
In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.
1919

20-
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
20+
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:
2121

2222
```js
2323
test('object assignment', () => {
@@ -29,7 +29,13 @@ test('object assignment', () => {
2929

3030
`toEqual` recursively checks every field of an object or array.
3131

32-
You can also test for the opposite of a matcher:
32+
:::tip
33+
34+
Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.
35+
36+
:::
37+
38+
You can also test for the opposite of a matcher using `not`:
3339

3440
```js
3541
test('adding positive numbers is not zero', () => {

0 commit comments

Comments
 (0)