Skip to content

Commit 36ecbeb

Browse files
committed
Merge branch 'main' into fix/global-setup-teardown-message-not-writable
2 parents 0ec6646 + 23cc165 commit 36ecbeb

File tree

221 files changed

+11172
-11357
lines changed

Some content is hidden

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

221 files changed

+11172
-11357
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ aliases:
1212
app-dir: ~/jest
1313

1414
orbs:
15-
node: circleci/node@5.0.3
15+
node: circleci/node@5.1.0
1616

1717
jobs:
1818
test-node:
@@ -58,5 +58,6 @@ workflows:
5858
name: test-node-partial-<< matrix.node-version >>
5959
matrix:
6060
parameters:
61+
# For some reason, v20 fails to run yarn install…
6162
node-version: ['14', '16', '18', '19']
6263
- test-jest-jasmine

.github/dependabot.yml

-10
This file was deleted.

.github/renovate.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:base"],
4+
"lockFileMaintenance": {"enabled": true, "automerge": true},
5+
"rangeStrategy": "replace",
6+
"postUpdateOptions": ["yarnDedupeHighest"],
7+
"packageRules": [
8+
{
9+
"matchPackageNames": ["@tsd/typescript", "typescript"],
10+
"groupName": "typescript"
11+
}
12+
]
13+
}

.github/workflows/issues.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
name: Questions
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Close Issue
16-
uses: peter-evans/close-issue@v2
17-
if: "${{ github.event.label.name == ':speech_balloon: Question' }}"
18-
with:
19-
comment: Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions.
15+
- if: "${{ github.event.label.name == ':speech_balloon: Question' }}"
16+
run: gh issue close $ISSUE --comment "Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions."
17+
env:
18+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
ISSUE: ${{ github.event.issue.html_url }}
2020
bug-without-repro:
2121
name: Bug reports without reproductions
2222
runs-on: ubuntu-latest
2323
steps:
24-
- name: Close Issue
25-
uses: peter-evans/close-issue@v2
26-
if: "${{ github.event.label.name == 'Needs Reproduction' }}"
27-
with:
28-
comment: As noted in the [Bug Report template](https://github.com/facebook/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example.
24+
- if: "${{ github.event.label.name == 'Needs Reproduction' }}"
25+
run: gh issue close $ISSUE --comment "As noted in the [Bug Report template](https://github.com/jestjs/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example."
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
ISSUE: ${{ github.event.issue.html_url }}

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
node-version: [14.x, 16.x, 18.x, 19.x]
15+
node-version: [14.x, 16.x, 18.x, 19.x, 20.x]
1616
shard: ['1/4', '2/4', '3/4', '4/4']
1717
name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }})
1818
runs-on: ${{ inputs.os }}

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

+111-111
Large diffs are not rendered by default.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

+2-2
Large diffs are not rendered by default.

.yarn/releases/yarn-3.5.0.cjs renamed to .yarn/releases/yarn-3.6.1.cjs

+280-279
Large diffs are not rendered by default.

.yarnrc.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ packageExtensions:
1313
"@svgr/core@*":
1414
peerDependencies:
1515
"@babel/core": ^7.1.6
16-
react-native-codegen@*:
17-
peerDependencies:
18-
"@babel/preset-env": ^7.1.6
1916
react-native@*:
2017
peerDependencies:
2118
"@babel/preset-env": ^7.1.6
@@ -28,4 +25,4 @@ plugins:
2825
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
2926
spec: "@yarnpkg/plugin-workspace-tools"
3027

31-
yarnPath: .yarn/releases/yarn-3.5.0.cjs
28+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

CHANGELOG.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,57 @@
22

33
### Features
44

5+
### Fixes
6+
7+
- `[jest-circus]` Fix snapshot matchers in concurrent tests when nr of tests exceeds `maxConcurrency` ([#14335](https://github.com/jestjs/jest/pull/14335))
8+
- `[@jest/core]` When running global setup and teardown, do not try to change the `message` property of the thrown error object when the `message` property is unwritable ([#14113](https://github.com/jestjs/jest/pull/14113))
9+
- `[jest-snapshot]` Move `@types/prettier` from `dependencies` to `devDependencies` ([#14328](https://github.com/jestjs/jest/pull/14328))
10+
- `[jest-reporters]` Add "skipped" and "todo" symbols to Github Actions Reporter ([#14309](https://github.com/jestjs/jest/pull/14309))
11+
12+
### Chore & Maintenance
13+
14+
- `[@jest/core]` Use `pluralize` from `jest-util` rather than own internal ([#14322](https://github.com/jestjs/jest/pull/14322))
15+
16+
### Performance
17+
18+
## 29.6.1
19+
20+
### Fixes
21+
22+
- `[jest-circus]` Revert [#14110](https://github.com/jestjs/jest/pull/14110) as it was a breaking change ([#14304](https://github.com/jestjs/jest/pull/14304))
23+
24+
## 29.6.0
25+
26+
### Features
27+
28+
- `[jest-circus, jest-snapshot]` Add support for snapshot matchers in concurrent tests ([#14139](https://github.com/jestjs/jest/pull/14139))
529
- `[jest-cli]` Include type definitions to generated config files ([#14078](https://github.com/facebook/jest/pull/14078))
630
- `[jest-snapshot]` Support arrays as property matchers ([#14025](https://github.com/facebook/jest/pull/14025))
31+
- `[jest-core, jest-circus, jest-reporter, jest-runner]` Added support for reporting about start individual test cases using jest-circus ([#14174](https://github.com/jestjs/jest/pull/14174))
732

833
### Fixes
934

35+
- `[jest-circus]` Prevent false test failures caused by promise rejections handled asynchronously ([#14110](https://github.com/jestjs/jest/pull/14110))
1036
- `[jest-config]` Handle frozen config object ([#14054](https://github.com/facebook/jest/pull/14054))
37+
- `[jest-config]` Allow `coverageDirectory` and `collectCoverageFrom` in project config ([#14180](https://github.com/jestjs/jest/pull/14180))
1138
- `[jest-core]` Always use workers in watch mode to avoid crashes ([#14059](https://github.com/facebook/jest/pull/14059)).
1239
- `[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))
1340
- `[jest-matcher-utils]` Fix copying value of inherited getters ([#14007](https://github.com/facebook/jest/pull/14007))
1441
- `[jest-mock]` Tweak typings to allow `jest.replaceProperty()` replace methods ([#14008](https://github.com/facebook/jest/pull/14008))
1542
- `[jest-mock]` Improve user input validation and error messages of `spyOn` and `replaceProperty` methods ([#14087](https://github.com/facebook/jest/pull/14087))
1643
- `[jest-runtime]` Bind `jest.isolateModulesAsync` to `this` ([#14083](https://github.com/facebook/jest/pull/14083))
44+
- `[jest-runtime]` Forward `wrapperLength` to the `Script` constructor as `columnOffset` for accurate debugging ([#14148](https://github.com/facebook/jest/pull/14148))
45+
- `[jest-runtime]` Guard `_isMockFunction` access with `in` ([#14188](https://github.com/facebook/jest/pull/14188))
1746
- `[jest-snapshot]` Fix a potential bug when not using prettier and improve performance ([#14036](https://github.com/facebook/jest/pull/14036))
1847
- `[@jest/transform]` Do not instrument `.json` modules ([#14048](https://github.com/facebook/jest/pull/14048))
19-
- `[jest-core]` When running global setup and teardown, do not try to change the `message` property of the thrown error object when the `message` property is unwritable
48+
- `[jest-worker]` Restart a shut down worker before sending it a task ([#14015](https://github.com/facebook/jest/pull/14015))
2049

2150
### Chore & Maintenance
2251

52+
- `[*]` Update `semver` dependency to get vulnerability fix ([#14262](https://github.com/jestjs/jest/pull/14262))
2353
- `[docs]` Updated documentation for the `--runTestsByPath` CLI command ([#14004](https://github.com/facebook/jest/pull/14004))
2454
- `[docs]` Updated documentation regarding the synchronous fallback when asynchronous code transforms are unavailable ([#14056](https://github.com/facebook/jest/pull/14056))
25-
- `[docs]` Update jest statistics of use and downloads in website Index.
26-
27-
### Performance
55+
- `[docs]` Update jest statistics of use and downloads in website Index.
2856

2957
## 29.5.0
3058

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<a href="https://github.com/facebook/jest/blob/main/LICENSE">
66
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Jest is released under the MIT license." />
77
</a>
8-
<a href="https://twitter.com/intent/follow?screen_name=fbjest">
9-
<img src="https://img.shields.io/twitter/follow/fbjest.svg?style=social&label=Follow%20@fbjest" alt="Follow on Twitter" />
8+
<a href="https://twitter.com/intent/follow?screen_name=jestjs_">
9+
<img src="https://img.shields.io/twitter/follow/jestjs_.svg?style=social&label=Follow%20@jestjs_" alt="Follow on Twitter" />
1010
</a>
1111
</p>
1212
<p align="center">

docs/Configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ module.exports = config;
16431643
import type {Config} from 'jest';
16441644

16451645
const config: Config = {
1646-
setupFilesAfterEnv: ['<rootDir>/setup-matchers.js'],
1646+
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
16471647
};
16481648

16491649
export default config;

docs/Es6ClassMocks.md

-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ You can mock/spy on them easily, here is an example:
311311
```javascript
312312
// your jest test file below
313313
import SoundPlayer from './sound-player';
314-
import SoundPlayerConsumer from './sound-player-consumer';
315314

316315
const staticMethodMock = jest
317316
.spyOn(SoundPlayer, 'brand')

docs/MoreResources.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ You will find a number of example test cases in the [`examples`](https://github.
2121

2222
Ask questions and find answers from other Jest users like you. [Reactiflux](https://discord.gg/j6FKKQQrW9) is a Discord chat where a lot of Jest discussion happens. Check out the `#testing` channel.
2323

24-
Follow the [Jest Twitter account](https://twitter.com/fbjest) and [blog](/blog/) to find out what's happening in the world of Jest.
24+
Follow the [Jest Twitter account](https://twitter.com/jestjs_) and [blog](/blog/) to find out what's happening in the world of Jest.

docs/SnapshotTesting.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Once you're finished, Jest will give you a summary before returning back to watc
106106

107107
Inline snapshots behave identically to external snapshots (`.snap` files), except the snapshot values are written automatically back into the source code. This means you can get the benefits of automatically generated snapshots without having to switch to an external file to make sure the correct value was written.
108108

109-
**Example:**
109+
Example:
110110

111111
First, you write a test, calling `.toMatchInlineSnapshot()` with no arguments:
112112

@@ -160,7 +160,7 @@ it('will fail every time', () => {
160160

161161
// Snapshot
162162
exports[`will fail every time 1`] = `
163-
Object {
163+
{
164164
"createdAt": 2018-05-19T23:36:09.816Z,
165165
"id": 3,
166166
"name": "LeBron James",
@@ -186,7 +186,7 @@ it('will check the matchers and pass', () => {
186186

187187
// Snapshot
188188
exports[`will check the matchers and pass 1`] = `
189-
Object {
189+
{
190190
"createdAt": Any<Date>,
191191
"id": Any<Number>,
192192
"name": "LeBron James",
@@ -211,7 +211,7 @@ it('will check the values and pass', () => {
211211

212212
// Snapshot
213213
exports[`will check the values and pass 1`] = `
214-
Object {
214+
{
215215
"createdAt": Any<Date>,
216216
"name": 'Bond... James Bond',
217217
}

docs/TutorialReact.md

+2-33
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ React 16 triggers these warnings due to how it checks element types, and the moc
209209
210210
### DOM Testing
211211
212-
If you'd like to assert, and manipulate your rendered components you can use [react-testing-library](https://github.com/kentcdodds/react-testing-library), [Enzyme](https://enzymejs.github.io/enzyme/), or React's [TestUtils](https://reactjs.org/docs/test-utils.html). The following two examples use react-testing-library and Enzyme.
212+
If you'd like to assert, and manipulate your rendered components you can use [@testing-library/react](https://github.com/testing-library/react-testing-library), [Enzyme](https://enzymejs.github.io/enzyme/), or React's [TestUtils](https://reactjs.org/docs/test-utils.html). The following example use `@testing-library/react`.
213213

214-
#### react-testing-library
214+
#### @testing-library/react
215215

216216
```bash npm2yarn
217217
npm install --save-dev @testing-library/react
@@ -261,37 +261,6 @@ it('CheckboxWithLabel changes the text after click', () => {
261261
262262
The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library).
263263
264-
#### Enzyme
265-
266-
```bash npm2yarn
267-
npm install --save-dev enzyme
268-
```
269-
270-
If you are using a React version below 15.5.0, you will also need to install `react-addons-test-utils`.
271-
272-
Let's rewrite the test from above using Enzyme instead of react-testing-library. We use Enzyme's [shallow renderer](https://enzymejs.github.io/enzyme/docs/api/shallow.html) in this example.
273-
274-
```tsx title="__tests__/CheckboxWithLabel-test.js"
275-
import Enzyme, {shallow} from 'enzyme';
276-
import Adapter from 'enzyme-adapter-react-16';
277-
import CheckboxWithLabel from '../CheckboxWithLabel';
278-
279-
Enzyme.configure({adapter: new Adapter()});
280-
281-
it('CheckboxWithLabel changes the text after click', () => {
282-
// Render a checkbox with label in the document
283-
const checkbox = shallow(<CheckboxWithLabel labelOn="On" labelOff="Off" />);
284-
285-
expect(checkbox.text()).toBe('Off');
286-
287-
checkbox.find('input').simulate('change');
288-
289-
expect(checkbox.text()).toBe('On');
290-
});
291-
```
292-
293-
The code for this example is available at [examples/enzyme](https://github.com/facebook/jest/tree/main/examples/enzyme).
294-
295264
### Custom transformers
296265
297266
If you need more advanced functionality, you can also build your own transformer. Instead of using `babel-jest`, here is an example of using `@babel/core`:

e2e/Utils.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import * as path from 'path';
99
import * as util from 'util';
10-
import dedent = require('dedent');
10+
import dedent from 'dedent';
1111
import {
1212
ExecaSyncError,
1313
SyncOptions as ExecaSyncOptions,
@@ -91,7 +91,7 @@ export const linkJestPackage = (packageName: string, cwd: string) => {
9191
};
9292

9393
export const makeTemplate =
94-
(str: string): ((values?: Array<unknown>) => string) =>
94+
(str: string): ((values?: Array<string>) => string) =>
9595
(values = []) =>
9696
str.replace(/\$(\d+)/g, (_match, number) => {
9797
if (!Array.isArray(values)) {
@@ -310,17 +310,6 @@ export const extractSummaries = (
310310
.map(({start, end}) => extractSortedSummary(stdout.slice(start, end)));
311311
};
312312

313-
export const normalizeIcons = (str: string) => {
314-
if (!str) {
315-
return str;
316-
}
317-
318-
// Make sure to keep in sync with `jest-util/src/specialChars`
319-
return str
320-
.replace(new RegExp('\u00D7', 'gu'), '\u2715')
321-
.replace(new RegExp('\u221A', 'gu'), '\u2713');
322-
};
323-
324313
// Certain environments (like CITGM and GH Actions) do not come with mercurial installed
325314
let hgIsInstalled: boolean | null = null;
326315

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

+9
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ exports[`Custom Reporters Integration on jest-circus push test case results for
1414
"onTestCaseResult: sample, status: todo, numExpectations: 0
1515
onTestFileResult testCaseResult 0: sample, status: todo, numExpectations: 0"
1616
`;
17+
18+
exports[`Custom Reporters Integration on jest-circus push test case start 1`] = `
19+
"onTestCaseStart: test 1, mode: undefined, ancestorTitles: Custom Reporters
20+
onTestCaseStart: test 2, mode: undefined, ancestorTitles: Custom Reporters"
21+
`;
22+
23+
exports[`Custom Reporters Integration on jest-circus doesn't push test case start for skip tests 1`] = `""`;
24+
25+
exports[`Custom Reporters Integration on jest-circus doesn't push test case start for todo tests 1`] = `""`;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ exports[`cannot have describe with no implementation 1`] = `
2424
Missing second argument. It must be a callback function.
2525
2626
> 1 | describe('describe, no implementation');
27-
| ^
27+
| ^
2828
29-
at Object.<anonymous> (__tests__/onlyConstructs.test.js:1:10)"
29+
at Object.<anonymous> (__tests__/onlyConstructs.test.js:1:40)"
3030
`;
3131
3232
exports[`cannot have describe with no implementation 2`] = `

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

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ exports[`--showConfig outputs config info and exits 1`] = `
88
"cache": false,
99
"cacheDirectory": "/tmp/jest",
1010
"clearMocks": false,
11+
"collectCoverageFrom": [],
12+
"coverageDirectory": "<<REPLACED_ROOT_DIR>>/coverage",
1113
"coveragePathIgnorePatterns": [
1214
"/node_modules/"
1315
],

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

+2-2
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:176:11)
49+
at Function.failing (../../packages/jest-jasmine2/build/jasmineAsyncInstall.js:175: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:176:11)
83+
at Function.failing (../../packages/jest-jasmine2/build/jasmineAsyncInstall.js:175:11)
8484
at Suite.failing (__tests__/worksWithConcurrentOnlyMode.test.js:13:22)
8585
at Object.describe (__tests__/worksWithConcurrentOnlyMode.test.js:8:1)
8686

0 commit comments

Comments
 (0)