Skip to content

Commit 0b22568

Browse files
committed
Merge branch 'main' into chinn/relative-paths
2 parents 3c22ef3 + 46285d8 commit 0b22568

File tree

185 files changed

+5616
-3888
lines changed

Some content is hidden

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

185 files changed

+5616
-3888
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ module.exports = {
160160
'e2e/failures/macros.js',
161161
'e2e/test-in-root/*.js',
162162
'e2e/test-match/test-suites/*',
163+
'e2e/test-match-default/dot-spec-tests/*',
163164
'packages/test-utils/src/ConditionalTest.ts',
164165
],
165166
env: {'jest/globals': true},
@@ -599,6 +600,7 @@ module.exports = {
599600
'unicorn/explicit-length-check': 'error',
600601
'unicorn/no-array-for-each': 'error',
601602
'unicorn/no-negated-condition': 'error',
603+
'unicorn/numeric-separators-style': 'error',
602604
'unicorn/prefer-default-parameters': 'error',
603605
'unicorn/prefer-includes': 'error',
604606
'unicorn/template-indent': 'error',

.github/workflows/nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ concurrency:
1111

1212
permissions:
1313
contents: read # to fetch code (actions/checkout)
14+
issues: write # to create an issue and comment in it
1415

1516
jobs:
1617
prepare-yarn-cache-ubuntu:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@
33
### Features
44

55
- `[jest-config]` [**BREAKING**] Add `mts` and `cts` to default `moduleFileExtensions` config ([#14369](https://github.com/facebook/jest/pull/14369))
6+
- `[jest-config]` [**BREAKING**] Update `testMatch` and `testRegex` default option for supporting `mjs`, `cjs`, `mts`, and `cts` ([#14584](https://github.com/jestjs/jest/pull/14584))
67
- `[@jest/core]` [**BREAKING**] Group together open handles with the same stack trace ([#13417](https://github.com/jestjs/jest/pull/13417), & [#14543](https://github.com/jestjs/jest/pull/14543))
78
- `[@jest/core, @jest/test-sequencer]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543))
89
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM to v22 ([#13825](https://github.com/jestjs/jest/pull/13825))
910
- `[@jest/fake-timers]` [**BREAKING**] Upgrade `@sinonjs/fake-timers` to v11 ([#14544](https://github.com/jestjs/jest/pull/14544))
1011
- `[@jest/schemas]` Upgrade `@sinclair/typebox` to v0.31 ([#14072](https://github.com/jestjs/jest/pull/14072))
12+
- `[@jest/types]` `test.each()`: Accept a readonly (`as const`) table properly ([#14565](https://github.com/jestjs/jest/pull/14565))
1113
- `[jest-snapshot]` [**BREAKING**] Add support for [Error causes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) in snapshots ([#13965](https://github.com/facebook/jest/pull/13965))
14+
- `[jest-snapshot]` Support Prettier 3 ([#14566](https://github.com/facebook/jest/pull/14566))
1215
- `[pretty-format]` [**BREAKING**] Do not render empty string children (`''`) in React plugin ([#14470](https://github.com/facebook/jest/pull/14470))
1316

1417
### Fixes
1518

1619
- `[babel-plugin-jest-hoist]` Use `denylist` instead of the deprecated `blacklist` for Babel 8 support ([#14109](https://github.com/jestjs/jest/pull/14109))
20+
- `[expect]` Check error instance type for `toThrow/toThrowError` ([#14576](https://github.com/jestjs/jest/pull/14576))
1721
- `[jest-circus]` [**BREAKING**] Prevent false test failures caused by promise rejections handled asynchronously ([#14315](https://github.com/jestjs/jest/pull/14315))
22+
- `[jest-config]` Make sure to respect `runInBand` option ([#14578](https://github.com/facebook/jest/pull/14578))
1823
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
1924
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
25+
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
2026
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
2127
- `[pretty-format]` [**BREAKING**] Print `ArrayBuffer` and `DataView` correctly ([#14290](https://github.com/facebook/jest/pull/14290))
2228
- `[jest-cli]` When specifying paths on the command line, only match against the relative paths of the test files ([#12519](https://github.com/facebook/jest/pull/12519))

constraints.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, DependencyRange2, Depende
2222
% @types/node in the root need to stay on ~14.14.45
2323
'@types/node',
2424
% upgrading the entire repository is a breaking change
25-
'glob'
25+
'glob',
26+
% repository and snapshot
27+
'prettier'
2628
]).
2729

2830
% Enforces that a dependency doesn't appear in both `dependencies` and `devDependencies`

docs/Configuration.md

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,42 +1145,6 @@ Default: `'prettier'`
11451145

11461146
Sets the path to the [`prettier`](https://prettier.io/) node module used to update inline snapshots.
11471147

1148-
<details>
1149-
<summary>Prettier version 3 is not supported!</summary>
1150-
1151-
You can either pass `prettierPath: null` in your config to disable using prettier if you don't need it, or use v2 of Prettier solely for Jest.
1152-
1153-
```json title="package.json"
1154-
{
1155-
"devDependencies": {
1156-
"prettier-2": "npm:prettier@^2"
1157-
}
1158-
}
1159-
```
1160-
1161-
```js tab
1162-
/** @type {import('jest').Config} */
1163-
const config = {
1164-
prettierPath: require.resolve('prettier-2'),
1165-
};
1166-
1167-
module.exports = config;
1168-
```
1169-
1170-
```ts tab
1171-
import type {Config} from 'jest';
1172-
1173-
const config: Config = {
1174-
prettierPath: require.resolve('prettier-2'),
1175-
};
1176-
1177-
export default config;
1178-
```
1179-
1180-
We hope to support Prettier v3 seamlessly out of the box in a future version of Jest. See [this](https://github.com/jestjs/jest/issues/14305) tracking issue.
1181-
1182-
</details>
1183-
11841148
### `projects` \[array&lt;string | ProjectConfig&gt;]
11851149

11861150
Default: `undefined`
@@ -2036,7 +2000,7 @@ This does not change the exit code in the case of Jest errors (e.g. invalid conf
20362000

20372001
### `testMatch` \[array&lt;string&gt;]
20382002

2039-
(default: `[ "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]`)
2003+
(default: `[ "**/__tests__/**/*.?([mc])[jt]s?(x)", "**/?(*.)+(spec|test).?([mc])[jt]s?(x)" ]`)
20402004

20412005
The glob patterns Jest uses to detect test files. By default it looks for `.js`, `.jsx`, `.ts` and `.tsx` files inside of `__tests__` folders, as well as any files with a suffix of `.test` or `.spec` (e.g. `Component.test.js` or `Component.spec.js`). It will also find files called `test.js` or `spec.js`.
20422006

@@ -2060,7 +2024,7 @@ These pattern strings match against the full path. Use the `<rootDir>` string to
20602024

20612025
### `testRegex` \[string | array&lt;string&gt;]
20622026

2063-
Default: `(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$`
2027+
Default: `(/__tests__/.*|(\\.|/)(test|spec))\\.[mc]?[jt]sx?$`
20642028

20652029
The pattern or patterns Jest uses to detect test files. By default it looks for `.js`, `.jsx`, `.ts` and `.tsx` files inside of `__tests__` folders, as well as any files with a suffix of `.test` or `.spec` (e.g. `Component.test.js` or `Component.spec.js`). It will also find files called `test.js` or `spec.js`. See also [`testMatch` [array&lt;string&gt;]](#testmatch-arraystring), but note that you cannot specify both options.
20662030

docs/ExpectAPI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ The type declaration of the matcher can live in a `.d.ts` file or in an imported
15051505

15061506
:::tip
15071507

1508-
Instead of importing `toBeWithinRange` module to the test file, you can enable the matcher for all tests by moving the `expect.extend` call to a [`setupFilesAfterEnv`](Configuration.md/#setupfilesafterenv-array) script:
1508+
Instead of importing `toBeWithinRange` module to the test file, you can enable the matcher for all tests by moving the `expect.extend` call to a [`setupFilesAfterEnv`](Configuration.md#setupfilesafterenv-array) script:
15091509

15101510
```js
15111511
import {expect} from '@jest/globals';

docs/GlobalAPI.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ describe.each([
298298
});
299299
```
300300

301-
#### 2. `` describe.each`table`(name, fn, timeout) ``
301+
#### 2. ``describe.each`table`(name, fn, timeout)``
302302

303303
- `table`: `Tagged Template Literal`
304304
- First row of variable name column headings separated with `|`
@@ -355,7 +355,7 @@ describe('my other beverage', () => {
355355

356356
### `describe.only.each(table)(name, fn)`
357357

358-
Also under the aliases: `fdescribe.each(table)(name, fn)` and `` fdescribe.each`table`(name, fn) ``
358+
Also under the aliases: `fdescribe.each(table)(name, fn)` and ``fdescribe.each`table`(name, fn)``
359359

360360
Use `describe.only.each` if you want to only run specific tests suites of data driven tests.
361361

@@ -379,7 +379,7 @@ test('will not be run', () => {
379379
});
380380
```
381381

382-
#### `` describe.only.each`table`(name, fn) ``
382+
#### ``describe.only.each`table`(name, fn)``
383383

384384
```js
385385
describe.only.each`
@@ -424,7 +424,7 @@ Using `describe.skip` is often a cleaner alternative to temporarily commenting o
424424

425425
### `describe.skip.each(table)(name, fn)`
426426

427-
Also under the aliases: `xdescribe.each(table)(name, fn)` and `` xdescribe.each`table`(name, fn) ``
427+
Also under the aliases: `xdescribe.each(table)(name, fn)` and ``xdescribe.each`table`(name, fn)``
428428

429429
Use `describe.skip.each` if you want to stop running a suite of data driven tests.
430430

@@ -448,7 +448,7 @@ test('will be run', () => {
448448
});
449449
```
450450

451-
#### `` describe.skip.each`table`(name, fn) ``
451+
#### ``describe.skip.each`table`(name, fn)``
452452

453453
```js
454454
describe.skip.each`
@@ -525,7 +525,7 @@ test.concurrent('subtraction 2 numbers', async () => {
525525

526526
:::tip
527527

528-
Use the [`maxConcurrency`](Configuration.md/#maxconcurrency-number) configuration option to prevent Jest from executing more than the specified amount of tests at the same time.
528+
Use the [`maxConcurrency`](Configuration.md#maxconcurrency-number) configuration option to prevent Jest from executing more than the specified amount of tests at the same time.
529529

530530
:::
531531

@@ -566,7 +566,7 @@ test.concurrent.each([
566566
});
567567
```
568568

569-
#### 2. `` test.concurrent.each`table`(name, fn, timeout) ``
569+
#### 2. ``test.concurrent.each`table`(name, fn, timeout)``
570570

571571
- `table`: `Tagged Template Literal`
572572
- First row of variable name column headings separated with `|`
@@ -613,7 +613,7 @@ test('will not be run', () => {
613613
});
614614
```
615615

616-
#### `` test.only.each`table`(name, fn) ``
616+
#### ``test.only.each`table`(name, fn)``
617617

618618
```js
619619
test.concurrent.only.each`
@@ -654,7 +654,7 @@ test('will be run', () => {
654654
});
655655
```
656656

657-
#### `` test.concurrent.skip.each`table`(name, fn) ``
657+
#### ``test.concurrent.skip.each`table`(name, fn)``
658658

659659
```js
660660
test.concurrent.skip.each`
@@ -673,7 +673,7 @@ test('will be run', () => {
673673

674674
### `test.each(table)(name, fn, timeout)`
675675

676-
Also under the alias: `it.each(table)(name, fn)` and `` it.each`table`(name, fn) ``
676+
Also under the alias: `it.each(table)(name, fn)` and ``it.each`table`(name, fn)``
677677

678678
Use `test.each` if you keep duplicating the same test with different data. `test.each` allows you to write the test once and pass data in.
679679

@@ -722,7 +722,7 @@ test.each([
722722
});
723723
```
724724

725-
#### 2. `` test.each`table`(name, fn, timeout) ``
725+
#### 2. ``test.each`table`(name, fn, timeout)``
726726

727727
- `table`: `Tagged Template Literal`
728728
- First row of variable name column headings separated with `|`
@@ -779,7 +779,7 @@ test.failing('it is equal', () => {
779779

780780
### `test.failing.each(name, fn, timeout)`
781781

782-
Also under the alias: `it.failing.each(table)(name, fn)` and `` it.failing.each`table`(name, fn) ``
782+
Also under the alias: `it.failing.each(table)(name, fn)` and ``it.failing.each`table`(name, fn)``
783783

784784
:::note
785785

@@ -851,7 +851,7 @@ Usually you wouldn't check code using `test.only` into source control - you woul
851851

852852
### `test.only.each(table)(name, fn)`
853853

854-
Also under the aliases: `it.only.each(table)(name, fn)`, `fit.each(table)(name, fn)`, `` it.only.each`table`(name, fn) `` and `` fit.each`table`(name, fn) ``
854+
Also under the aliases: `it.only.each(table)(name, fn)`, `fit.each(table)(name, fn)`, ``it.only.each`table`(name, fn)`` and ``fit.each`table`(name, fn)``
855855

856856
Use `test.only.each` if you want to only run specific tests with different test data.
857857

@@ -873,7 +873,7 @@ test('will not be run', () => {
873873
});
874874
```
875875

876-
#### `` test.only.each`table`(name, fn) ``
876+
#### ``test.only.each`table`(name, fn)``
877877

878878
```js
879879
test.only.each`
@@ -914,7 +914,7 @@ You could comment the test out, but it's often a bit nicer to use `test.skip` be
914914

915915
### `test.skip.each(table)(name, fn)`
916916

917-
Also under the aliases: `it.skip.each(table)(name, fn)`, `xit.each(table)(name, fn)`, `xtest.each(table)(name, fn)`, `` it.skip.each`table`(name, fn) ``, `` xit.each`table`(name, fn) `` and `` xtest.each`table`(name, fn) ``
917+
Also under the aliases: `it.skip.each(table)(name, fn)`, `xit.each(table)(name, fn)`, `xtest.each(table)(name, fn)`, ``it.skip.each`table`(name, fn)``, ``xit.each`table`(name, fn)`` and ``xtest.each`table`(name, fn)``
918918

919919
Use `test.skip.each` if you want to stop running a collection of data driven tests.
920920

@@ -936,7 +936,7 @@ test('will be run', () => {
936936
});
937937
```
938938

939-
#### `` test.skip.each`table`(name, fn) ``
939+
#### ``test.skip.each`table`(name, fn)``
940940

941941
```js
942942
test.skip.each`

docs/JestObjectAPI.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,17 @@ Returns the `jest` object for chaining.
344344

345345
:::tip
346346

347-
Writing tests in TypeScript? Use the [`jest.Mocked`](MockFunctionAPI.md/#jestmockedsource) utility type or the [`jest.mocked()`](MockFunctionAPI.md/#jestmockedsource-options) helper method to have your mocked modules typed.
347+
Writing tests in TypeScript? Use the [`jest.Mocked`](MockFunctionAPI.md#jestmockedsource) utility type or the [`jest.mocked()`](MockFunctionAPI.md#jestmockedsource-options) helper method to have your mocked modules typed.
348348

349349
:::
350350

351351
### `jest.Mocked<Source>`
352352

353-
See [TypeScript Usage](MockFunctionAPI.md/#jestmockedsource) chapter of Mock Functions page for documentation.
353+
See [TypeScript Usage](MockFunctionAPI.md#jestmockedsource) chapter of Mock Functions page for documentation.
354354

355355
### `jest.mocked(source, options?)`
356356

357-
See [TypeScript Usage](MockFunctionAPI.md/#jestmockedsource-options) chapter of Mock Functions page for documentation.
357+
See [TypeScript Usage](MockFunctionAPI.md#jestmockedsource-options) chapter of Mock Functions page for documentation.
358358

359359
### `jest.unmock(moduleName)`
360360

docs/MockFunctionAPI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ afterEach(() => {
746746
});
747747

748748
test('renders correctly with a given date', () => {
749-
spiedDateNow = setDateNow(1482363367071);
749+
spiedDateNow = setDateNow(1_482_363_367_071);
750750
// ...
751751

752752
expect(spiedDateNow).toHaveBeenCalledTimes(1);

docs/MockFunctions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const otherObj = {
272272

273273
## Mock Names
274274

275-
You can optionally provide a name for your mock functions, which will be displayed instead of `'jest.fn()'` in the test error output. Use [`.mockName()`](MockFunctionAPI.md/#mockfnmocknamename) if you want to be able to quickly identify the mock function reporting an error in your test output.
275+
You can optionally provide a name for your mock functions, which will be displayed instead of `'jest.fn()'` in the test error output. Use [`.mockName()`](MockFunctionAPI.md#mockfnmocknamename) if you want to be able to quickly identify the mock function reporting an error in your test output.
276276

277277
```javascript
278278
const myMockFn = jest

0 commit comments

Comments
 (0)