Skip to content

Commit f6d0c5a

Browse files
authored
Merge branch 'main' into feat/programmatic-api
2 parents 6a26f7f + 94915dd commit f6d0c5a

File tree

192 files changed

+2653
-1893
lines changed

Some content is hidden

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

192 files changed

+2653
-1893
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@ workflows:
5858
name: test-node-partial-<< matrix.node-version >>
5959
matrix:
6060
parameters:
61-
# For some reason, v20 fails to run yarn install…
62-
node-version: ['16', '18']
61+
node-version: ['16', '18', '20', '21']
6362
- test-jest-jasmine

.eslintrc.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ module.exports = {
4646
rules: {
4747
'@typescript-eslint/array-type': ['error', {default: 'generic'}],
4848
'@typescript-eslint/ban-types': 'error',
49+
'@typescript-eslint/consistent-type-imports': [
50+
'error',
51+
{fixStyle: 'inline-type-imports', disallowTypeAnnotations: false},
52+
],
53+
'@typescript-eslint/no-import-type-side-effects': 'error',
4954
'@typescript-eslint/no-inferrable-types': 'error',
5055
'@typescript-eslint/no-unused-vars': [
5156
'error',
@@ -278,6 +283,16 @@ module.exports = {
278283
'no-restricted-imports': 'off',
279284
},
280285
},
286+
{
287+
files: ['examples/angular/**/*'],
288+
rules: {
289+
// Angular DI for some reason doesn't work with type imports
290+
'@typescript-eslint/consistent-type-imports': [
291+
'error',
292+
{prefer: 'no-type-imports', disallowTypeAnnotations: false},
293+
],
294+
},
295+
},
281296
{
282297
files: 'packages/**/*.ts',
283298
rules: {
@@ -416,6 +431,7 @@ module.exports = {
416431
'handle-callback-err': 'off',
417432
'id-length': 'off',
418433
'id-match': 'off',
434+
'import/no-duplicates': 'error',
419435
'import/no-extraneous-dependencies': [
420436
'error',
421437
{

.github/workflows/nodejs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- uses: actions/checkout@v4
3838
with:
3939
persist-credentials: false
40-
- uses: actions/setup-node@v3
40+
- uses: actions/setup-node@v4
4141
with:
4242
node-version: lts/*
4343
cache: yarn
@@ -63,7 +63,7 @@ jobs:
6363
- uses: actions/checkout@v4
6464
with:
6565
persist-credentials: false
66-
- uses: actions/setup-node@v3
66+
- uses: actions/setup-node@v4
6767
with:
6868
node-version: lts/*
6969
cache: yarn
@@ -85,7 +85,7 @@ jobs:
8585
- uses: actions/checkout@v4
8686
with:
8787
persist-credentials: false
88-
- uses: actions/setup-node@v3
88+
- uses: actions/setup-node@v4
8989
with:
9090
node-version: lts/*
9191
cache: yarn
@@ -112,7 +112,7 @@ jobs:
112112
- uses: actions/checkout@v4
113113
with:
114114
persist-credentials: false
115-
- uses: actions/setup-node@v3
115+
- uses: actions/setup-node@v4
116116
with:
117117
node-version: lts/*
118118
cache: yarn
@@ -165,7 +165,7 @@ jobs:
165165
with:
166166
persist-credentials: false
167167
- name: Use Node.js LTS
168-
uses: actions/setup-node@v3
168+
uses: actions/setup-node@v4
169169
with:
170170
node-version: lts/*
171171
cache: yarn
@@ -190,7 +190,7 @@ jobs:
190190
with:
191191
persist-credentials: false
192192
- name: Use Node.js LTS
193-
uses: actions/setup-node@v3
193+
uses: actions/setup-node@v4
194194
with:
195195
node-version: lts/*
196196
cache: yarn

.github/workflows/prepare-cache.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
persist-credentials: false
1919

20-
- uses: actions/setup-node@v3
20+
- uses: actions/setup-node@v4
2121
with:
2222
node-version: lts/*
2323
cache: yarn

.github/workflows/test-nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
persist-credentials: false
2323
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4
2525
with:
2626
node-version: 21-nightly
2727
cache: yarn
@@ -48,7 +48,7 @@ jobs:
4848
with:
4949
persist-credentials: false
5050
- name: Use Node.js LTS
51-
uses: actions/setup-node@v3
51+
uses: actions/setup-node@v4
5252
with:
5353
node-version: 21-nightly
5454
cache: yarn

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: [16.x, 18.x, 20.x]
18+
node-version: [16.x, 18.x, 20.x, 21.x]
1919
name: Node v${{ matrix.node-version }}
2020
runs-on: ${{ inputs.os }}
2121

@@ -24,7 +24,7 @@ jobs:
2424
with:
2525
persist-credentials: false
2626
- name: Use Node.js ${{ matrix.node-version }}
27-
uses: actions/setup-node@v3
27+
uses: actions/setup-node@v4
2828
with:
2929
node-version: ${{ matrix.node-version }}
3030
cache: yarn
@@ -47,7 +47,7 @@ jobs:
4747
with:
4848
persist-credentials: false
4949
- name: Use Node.js LTS
50-
uses: actions/setup-node@v3
50+
uses: actions/setup-node@v4
5151
with:
5252
node-version: lts/*
5353
cache: yarn

CHANGELOG.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@
3535

3636
### Performance
3737

38-
- `[*]` [**BREAKING**] Bundle all of Jest's modules into `index.js` ([#12348](https://github.com/jestjs/jest/pull/12348) & [#14550](https://github.com/jestjs/jest/pull/14550))
38+
- `[*]` [**BREAKING**] Bundle all of Jest's modules into `index.js` ([#12348](https://github.com/jestjs/jest/pull/12348), [#14550](https://github.com/jestjs/jest/pull/14550) & [#14661](https://github.com/jestjs/jest/pull/14661))
3939

4040
### Chore & Maintenance
4141

4242
- `[*]` [**BREAKING**] Drop support for Node.js versions 14 and 19 ([#14460](https://github.com/jestjs/jest/pull/14460))
4343
- `[*]` [**BREAKING**] Drop support for `typescript@4.3`, minimum version is now `5.0` ([#14542](https://github.com/facebook/jest/pull/14542))
4444
- `[*]` Depend on exact versions of monorepo dependencies instead of `^` range ([#14553](https://github.com/facebook/jest/pull/14553))
45+
- `[*]` [**BREAKING**] Add ESM wrapper for all of Jest's modules ([#14661](https://github.com/jestjs/jest/pull/14661))
4546
- `[babel-jest, babel-preset-jest]` [**BREAKING**] Increase peer dependency of `@babel/core` to `^7.11` ([#14109](https://github.com/jestjs/jest/pull/14109))
4647
- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490))
48+
- `[docs]` Fix typos in `CHANGELOG.md` and `packages/jest-validate/README.md` ([#14640](https://github.com/jestjs/jest/pull/14640))
49+
- `[docs]` Don't use alias matchers in docs ([#14631](https://github.com/facebook/jest/pull/14631))
4750

4851
## 29.7.0
4952

@@ -633,7 +636,7 @@
633636

634637
### Fixes
635638

636-
- `[*]` Use `sha256` instead of `md5` as hashing algortihm for compatibility with FIPS systems ([#12722](https://github.com/facebook/jest/pull/12722))
639+
- `[*]` Use `sha256` instead of `md5` as hashing algorithm for compatibility with FIPS systems ([#12722](https://github.com/facebook/jest/pull/12722))
637640
- `[babel-jest]` [**BREAKING**] Pass `rootDir` as `root` in Babel's options ([#12689](https://github.com/facebook/jest/pull/12689))
638641
- `[expect]` Move typings of `.not`, `.rejects` and `.resolves` modifiers outside of `Matchers` interface ([#12346](https://github.com/facebook/jest/pull/12346))
639642
- `[expect]` Throw useful error if `expect.extend` is called with invalid matchers ([#12488](https://github.com/facebook/jest/pull/12488))
@@ -1440,7 +1443,7 @@
14401443
- `[*]` Upgrade to chalk@4 ([#9752](https://github.com/facebook/jest/pull/9752))
14411444
- `[*]` Remove usage of `realpath-native` ([#9952](https://github.com/facebook/jest/pull/9952))
14421445
- `[docs]` Fix example reference implementation to use Jest with Phabricator ([#8662](https://github.com/facebook/jest/pull/8662))
1443-
- `[docs]` Added default compiler to tranform ([#8583](https://github.com/facebook/jest/pull/8583))
1446+
- `[docs]` Added default compiler to transform ([#8583](https://github.com/facebook/jest/pull/8583))
14441447
- `[docs]` Updated Testing Frameworks guide with React; make it generic ([#9106](https://github.com/facebook/jest/pull/9106))
14451448
- `[expect, jest-mock, pretty-format]` [**BREAKING**] Remove `build-es5` from package ([#9945](https://github.com/facebook/jest/pull/9945))
14461449
- `[@jest/fake-timers, @jest/environment]` [**BREAKING**] Rename `LolexFakeTimers` to `ModernFakeTimers` ([#9960](https://github.com/facebook/jest/pull/9960))
@@ -3480,7 +3483,7 @@ See <https://jestjs.io/blog/2016/12/15/2016-in-jest>
34803483
- Added `--watchAll`, made `--watch` interactive and added the ability to update snapshots and select test patterns in watch mode.
34813484
- Jest uses verbose mode when running a single test file.
34823485
- Console messages are now buffered and printed along with the test results.
3483-
- Fix `testEnvironment` resolution to prefer `jest-environment-{name}` instead of `{name}` only. This prevents a module colision when using `jsdom` as test environment.
3486+
- Fix `testEnvironment` resolution to prefer `jest-environment-{name}` instead of `{name}` only. This prevents a module collision when using `jsdom` as test environment.
34843487
- `moduleNameMapper` now uses a resolution algorithm.
34853488
- Improved performance for small test runs.
34863489
- Improved API documentation.
@@ -3619,7 +3622,7 @@ See <https://jestjs.io/blog/2016/12/15/2016-in-jest>
36193622
- Clear the terminal window when using `--watch`.
36203623
- By default, `--watch` will now only runs tests related to changed files. `--watch=all` can be used to run all tests on file system changes.
36213624
- Debounce `--watch` re-runs to not trigger test runs during a branch switch in version control.
3622-
- Added `jest.fn()` and `jest.fn(implementation)` as convenient shorcuts for `jest.genMockFunction()` and `jest.genMockFunction().mockImplementation()`.
3625+
- Added `jest.fn()` and `jest.fn(implementation)` as convenient shortcuts for `jest.genMockFunction()` and `jest.genMockFunction().mockImplementation()`.
36233626
- Added an `automock` option to turn off automocking globally.
36243627
- Added a "no tests found" message if no tests can be found.
36253628
- Jest sets `process.NODE_ENV` to `test` unless otherwise specified.

docs/ExpectAPI.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ Check out the section on [Inline Snapshots](SnapshotTesting.md#inline-snapshots)
888888

889889
### `expect.anything()`
890890

891-
`expect.anything()` matches anything but `null` or `undefined`. You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a non-null argument:
891+
`expect.anything()` matches anything but `null` or `undefined`. You can use it inside `toEqual` or `toHaveBeenCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a non-null argument:
892892

893893
```js
894894
test('map calls its argument with a non-null argument', () => {
@@ -900,7 +900,7 @@ test('map calls its argument with a non-null argument', () => {
900900

901901
### `expect.any(constructor)`
902902

903-
`expect.any(constructor)` matches anything that was created with the given constructor or if it's a primitive that is of the passed type. You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a number:
903+
`expect.any(constructor)` matches anything that was created with the given constructor or if it's a primitive that is of the passed type. You can use it inside `toEqual` or `toHaveBeenCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a number:
904904

905905
```js
906906
class Cat {}
@@ -931,7 +931,7 @@ test('randocall calls its callback with a number', () => {
931931

932932
You can use it instead of a literal value:
933933

934-
- in `toEqual` or `toBeCalledWith`
934+
- in `toEqual` or `toHaveBeenCalledWith`
935935
- to match a property in `objectContaining` or `toMatchObject`
936936

937937
```js
@@ -1063,7 +1063,7 @@ describe('not.stringContaining', () => {
10631063

10641064
You can use it instead of a literal value:
10651065

1066-
- in `toEqual` or `toBeCalledWith`
1066+
- in `toEqual` or `toHaveBeenCalledWith`
10671067
- to match an element in `arrayContaining`
10681068
- to match a property in `objectContaining` or `toMatchObject`
10691069

docs/MockFunctionAPI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ export function setDateNow(now: number): jest.Spied<typeof Date.now> {
736736
```
737737

738738
```ts
739-
import {afterEach, expect, jest, test} from '@jest/globals';
739+
import {afterEach, expect, type jest, test} from '@jest/globals';
740740
import {setDateNow} from './__utils__/setDateNow';
741741

742742
let spiedDateNow: jest.Spied<typeof Date.now> | undefined = undefined;

docs/TimerMocks.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ test('calls the callback after 1 second', () => {
5353
timerGame(callback);
5454

5555
// At this point in time, the callback should not have been called yet
56-
expect(callback).not.toBeCalled();
56+
expect(callback).not.toHaveBeenCalled();
5757

5858
// Fast-forward until all timers have been executed
5959
jest.runAllTimers();
6060

6161
// Now our callback should have been called!
62-
expect(callback).toBeCalled();
62+
expect(callback).toHaveBeenCalled();
6363
expect(callback).toHaveBeenCalledTimes(1);
6464
});
6565
```
@@ -109,7 +109,7 @@ describe('infiniteTimerGame', () => {
109109
jest.runOnlyPendingTimers();
110110

111111
// At this point, our 1-second timer should have fired its callback
112-
expect(callback).toBeCalled();
112+
expect(callback).toHaveBeenCalled();
113113

114114
// And it should have created a new timer to start the game over in
115115
// 10 seconds
@@ -154,13 +154,13 @@ it('calls the callback after 1 second via advanceTimersByTime', () => {
154154
timerGame(callback);
155155

156156
// At this point in time, the callback should not have been called yet
157-
expect(callback).not.toBeCalled();
157+
expect(callback).not.toHaveBeenCalled();
158158

159159
// Fast-forward until all timers have been executed
160160
jest.advanceTimersByTime(1000);
161161

162162
// Now our callback should have been called!
163-
expect(callback).toBeCalled();
163+
expect(callback).toHaveBeenCalled();
164164
expect(callback).toHaveBeenCalledTimes(1);
165165
});
166166
```
@@ -181,12 +181,12 @@ it('calls the animation frame callback after advanceTimersToNextFrame()', () =>
181181
requestAnimationFrame(callback);
182182

183183
// At this point in time, the callback should not have been called yet
184-
expect(callback).not.toBeCalled();
184+
expect(callback).not.toHaveBeenCalled();
185185

186186
jest.advanceTimersToNextFrame();
187187

188188
// Now our callback should have been called!
189-
expect(callback).toBeCalled();
189+
expect(callback).toHaveBeenCalled();
190190
expect(callback).toHaveBeenCalledTimes(1);
191191
});
192192
```

0 commit comments

Comments
 (0)