Skip to content

Commit 48a5a94

Browse files
authored
Merge branch 'main' into feat/programmatic-api
2 parents a749243 + 57e9872 commit 48a5a94

File tree

68 files changed

+5106
-3963
lines changed

Some content is hidden

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

68 files changed

+5106
-3963
lines changed

.github/workflows/close-stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Close stale issues and PRs'
22
on:
33
schedule:
4-
- cron: '*/10 * * * *'
4+
- cron: '0 * * * *'
55

66
permissions:
77
issues: write # to close stale issues (actions/stale)

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22

33
### Features
44

5+
- `[jest-cli]` Include type definitions to generated config files ([#14078](https://github.com/facebook/jest/pull/14078))
56
- `[jest-snapshot]` Support arrays as property matchers ([#14025](https://github.com/facebook/jest/pull/14025))
67

78
### Fixes
89

910
- `[jest-config]` Handle frozen config object ([#14054](https://github.com/facebook/jest/pull/14054))
11+
- `[jest-core]` Always use workers in watch mode to avoid crashes ([#14059](https://github.com/facebook/jest/pull/14059)).
1012
- `[jest-environment-jsdom, jest-environment-node]` Fix assignment of `customExportConditions` via `testEnvironmentOptions` when custom env subclass defines a default value ([#13989](https://github.com/facebook/jest/pull/13989))
1113
- `[jest-matcher-utils]` Fix copying value of inherited getters ([#14007](https://github.com/facebook/jest/pull/14007))
1214
- `[jest-mock]` Tweak typings to allow `jest.replaceProperty()` replace methods ([#14008](https://github.com/facebook/jest/pull/14008))
15+
- `[jest-mock]` Improve user input validation and error messages of `spyOn` and `replaceProperty` methods ([#14087](https://github.com/facebook/jest/pull/14087))
16+
- `[jest-runtime]` Bind `jest.isolateModulesAsync` to `this` ([#14083](https://github.com/facebook/jest/pull/14083))
1317
- `[jest-snapshot]` Fix a potential bug when not using prettier and improve performance ([#14036](https://github.com/facebook/jest/pull/14036))
1418
- `[@jest/transform]` Do not instrument `.json` modules ([#14048](https://github.com/facebook/jest/pull/14048))
1519

1620
### Chore & Maintenance
1721

1822
- `[docs]` Updated documentation for the `--runTestsByPath` CLI command ([#14004](https://github.com/facebook/jest/pull/14004))
1923
- `[docs]` Updated documentation regarding the synchronous fallback when asynchronous code transforms are unavailable ([#14056](https://github.com/facebook/jest/pull/14056))
24+
- `[docs]` Update jest statistics of use and downloads in website Index.
2025

2126
### Performance
2227

docs/JestObjectAPI.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,30 +1039,42 @@ Use the [`--showSeed`](CLI.md#--showseed) flag to print the seed in the test rep
10391039

10401040
Returns `true` if test environment has been torn down.
10411041

1042-
### `jest.retryTimes(numRetries, options)`
1042+
### `jest.retryTimes(numRetries, options?)`
10431043

1044-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. `options` are optional. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner! This must live at the top-level of a test file or in a describe block. Retries _will not_ work if `jest.retryTimes()` is called in a `beforeEach` or a `test` block.
1045-
1046-
Example in a test:
1044+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
10471045

10481046
```js
10491047
jest.retryTimes(3);
1048+
10501049
test('will fail', () => {
10511050
expect(true).toBe(false);
10521051
});
10531052
```
10541053

1055-
If `logErrorsBeforeRetry` is enabled, Jest will log the error(s) that caused the test to fail to the console, providing visibility on why a retry occurred.
1054+
If `logErrorsBeforeRetry` option is enabled, error(s) that caused the test to fail will be logged to the console.
10561055

10571056
```js
10581057
jest.retryTimes(3, {logErrorsBeforeRetry: true});
1058+
10591059
test('will fail', () => {
10601060
expect(true).toBe(false);
10611061
});
10621062
```
10631063

10641064
Returns the `jest` object for chaining.
10651065

1066+
:::caution
1067+
1068+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
1069+
1070+
:::
1071+
1072+
:::info
1073+
1074+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
1075+
1076+
:::
1077+
10661078
### `jest.setTimeout(timeout)`
10671079

10681080
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called. The default timeout interval is 5 seconds if this method is not called.

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:134:11)
19+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:140: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:97:11)
34+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:103: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:134:11)
49+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:140: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:97:11)
63+
at eventHandler (../../packages/jest-circus/build/eventHandler.js:103:11)
6464
at afterAll (__tests__/asyncDefinition.test.js:19:3)"
6565
`;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ FAIL __tests__/worksWithConcurrentMode.test.js
4646
15 | });
4747
16 |
4848
49-
at Function.failing (../../packages/jest-jasmine2/build/jasmineAsyncInstall.js:166:11)
49+
at Function.failing (../../packages/jest-jasmine2/build/jasmineAsyncInstall.js:176:11)
5050
at Suite.failing (__tests__/worksWithConcurrentMode.test.js:13:17)
5151
at Object.describe (__tests__/worksWithConcurrentMode.test.js:8:1)
5252
@@ -80,7 +80,7 @@ FAIL __tests__/worksWithConcurrentOnlyMode.test.js
8080
15 | });
8181
16 |
8282
83-
at Function.failing (../../packages/jest-jasmine2/build/jasmineAsyncInstall.js:166:11)
83+
at Function.failing (../../packages/jest-jasmine2/build/jasmineAsyncInstall.js:176:11)
8484
at Suite.failing (__tests__/worksWithConcurrentOnlyMode.test.js:13:22)
8585
at Object.describe (__tests__/worksWithConcurrentOnlyMode.test.js:8:1)
8686
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[`all 3 test files should complete 1`] = `
4+
"Test Suites: 1 failed, 2 passed, 3 total
5+
Tests: 2 passed, 2 total
6+
Snapshots: 0 total
7+
Time: <<REPLACED>>
8+
Ran all test suites."
9+
`;
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+
8+
import {extractSummary} from '../Utils';
9+
import runJest from '../runJest';
10+
11+
it('all 3 test files should complete', () => {
12+
const result = runJest('worker-restart-before-send');
13+
const {summary} = extractSummary(result.stderr);
14+
expect(summary).toMatchSnapshot();
15+
});

0 commit comments

Comments
 (0)