Skip to content

Commit 0db4f21

Browse files
authored
Merge branch 'main' into renovate/picomatch-3.x
2 parents 9aae8ac + 6cbba98 commit 0db4f21

File tree

184 files changed

+4182
-5571
lines changed

Some content is hidden

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

184 files changed

+4182
-5571
lines changed

.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
{

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
- `[jest-circus, jest-expect, jest-snapshot]` Pass `test.failing` tests when containing failing snapshot matchers ([#14313](https://github.com/jestjs/jest/pull/14313))
2525
- `[jest-config]` Make sure to respect `runInBand` option ([#14578](https://github.com/facebook/jest/pull/14578))
2626
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
27+
- `[@jest/expect-utils]` [**BREAKING**] exclude non-enumerable in object matching ([#14670](https://github.com/jestjs/jest/pull/14670))
28+
- `[@jest/expect-utils]` Fix comparison of `URL` ([#14672](https://github.com/jestjs/jest/pull/14672))
2729
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
2830
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
2931
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
@@ -35,18 +37,23 @@
3537

3638
### Performance
3739

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))
40+
- `[*]` [**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))
3941

4042
### Chore & Maintenance
4143

4244
- `[*]` [**BREAKING**] Drop support for Node.js versions 14 and 19 ([#14460](https://github.com/jestjs/jest/pull/14460))
4345
- `[*]` [**BREAKING**] Drop support for `typescript@4.3`, minimum version is now `5.0` ([#14542](https://github.com/facebook/jest/pull/14542))
4446
- `[*]` Depend on exact versions of monorepo dependencies instead of `^` range ([#14553](https://github.com/facebook/jest/pull/14553))
47+
- `[*]` [**BREAKING**] Add ESM wrapper for all of Jest's modules ([#14661](https://github.com/jestjs/jest/pull/14661))
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))
4550
- `[babel-jest, babel-preset-jest]` [**BREAKING**] Increase peer dependency of `@babel/core` to `^7.11` ([#14109](https://github.com/jestjs/jest/pull/14109))
51+
- `[expect]` [**BREAKING**] Remove `.toBeCalled()`, `.toBeCalledTimes()`, `.toBeCalledWith()`, `.lastCalledWith()`, `.nthCalledWith()`, `.toReturn()`, `.toReturnTimes()`, `.toReturnWith()`, `.lastReturnedWith()`, `.nthReturnedWith()` and `.toThrowError()` matcher aliases ([#14632](https://github.com/facebook/jest/pull/14632))
4652
- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490))
53+
- `[jest-config, @jest/core, jest-util]` Upgrade `ci-info` ([#14655](https://github.com/jestjs/jest/pull/14655))
54+
- `[jest-mock]` [**BREAKING**] Remove `MockFunctionMetadataType`, `MockFunctionMetadata` and `SpyInstance` types ([#14621](https://github.com/jestjs/jest/pull/14621))
55+
- `[jest-transform]` Upgrade `write-file-atomic` ([#14274](https://github.com/jestjs/jest/pull/14274))
4756
- `[jest-util]` Upgrade `picomatch` to v3 ([#14653](https://github.com/jestjs/jest/pull/14653))
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))
5057

5158
## 29.7.0
5259

docs/ExpectAPI.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ Although the `.toBe` matcher **checks** referential identity, it **reports** a d
144144

145145
### `.toHaveBeenCalled()`
146146

147-
Also under the alias: `.toBeCalled()`
148-
149147
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.
150148

151149
For example, let's say you have a `drinkAll(drink, flavour)` function that takes a `drink` function and applies it to all available beverages. You might want to check that `drink` gets called for `'lemon'`, but not for `'octopus'`, because `'octopus'` flavour is really weird and why would anything be octopus-flavoured? You can do that with this test suite:
@@ -174,8 +172,6 @@ describe('drinkAll', () => {
174172

175173
### `.toHaveBeenCalledTimes(number)`
176174

177-
Also under the alias: `.toBeCalledTimes(number)`
178-
179175
Use `.toHaveBeenCalledTimes` to ensure that a mock function got called exact number of times.
180176

181177
For example, let's say you have a `drinkEach(drink, Array<flavor>)` function that takes a `drink` function and applies it to array of passed beverages. You might want to check that drink function was called exact number of times. You can do that with this test suite:
@@ -190,8 +186,6 @@ test('drinkEach drinks each drink', () => {
190186

191187
### `.toHaveBeenCalledWith(arg1, arg2, ...)`
192188

193-
Also under the alias: `.toBeCalledWith()`
194-
195189
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.
196190

197191
For example, let's say that you can register a beverage with a `register` function, and `applyToAll(f)` should apply the function `f` to all registered beverages. To make sure this works, you could write:
@@ -208,8 +202,6 @@ test('registration applies correctly to orange La Croix', () => {
208202

209203
### `.toHaveBeenLastCalledWith(arg1, arg2, ...)`
210204

211-
Also under the alias: `.lastCalledWith(arg1, arg2, ...)`
212-
213205
If you have a mock function, you can use `.toHaveBeenLastCalledWith` to test what arguments it was last called with. For example, let's say you have a `applyToAllFlavors(f)` function that applies `f` to a bunch of flavors, and you want to ensure that when you call it, the last flavor it operates on is `'mango'`. You can write:
214206

215207
```js
@@ -222,8 +214,6 @@ test('applying to all flavors does mango last', () => {
222214

223215
### `.toHaveBeenNthCalledWith(nthCall, arg1, arg2, ....)`
224216

225-
Also under the alias: `.nthCalledWith(nthCall, arg1, arg2, ...)`
226-
227217
If you have a mock function, you can use `.toHaveBeenNthCalledWith` to test what arguments it was nth called with. For example, let's say you have a `drinkEach(drink, Array<flavor>)` function that applies `f` to a bunch of flavors, and you want to ensure that when you call it, the first flavor it operates on is `'lemon'` and the second one is `'octopus'`. You can write:
228218

229219
```js
@@ -243,8 +233,6 @@ The nth argument must be positive integer starting from 1.
243233

244234
### `.toHaveReturned()`
245235

246-
Also under the alias: `.toReturn()`
247-
248236
If you have a mock function, you can use `.toHaveReturned` to test that the mock function successfully returned (i.e., did not throw an error) at least one time. For example, let's say you have a mock `drink` that returns `true`. You can write:
249237

250238
```js
@@ -259,8 +247,6 @@ test('drinks returns', () => {
259247

260248
### `.toHaveReturnedTimes(number)`
261249

262-
Also under the alias: `.toReturnTimes(number)`
263-
264250
Use `.toHaveReturnedTimes` to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times. Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
265251

266252
For example, let's say you have a mock `drink` that returns `true`. You can write:
@@ -278,8 +264,6 @@ test('drink returns twice', () => {
278264

279265
### `.toHaveReturnedWith(value)`
280266

281-
Also under the alias: `.toReturnWith(value)`
282-
283267
Use `.toHaveReturnedWith` to ensure that a mock function returned a specific value.
284268

285269
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
@@ -297,8 +281,6 @@ test('drink returns La Croix', () => {
297281

298282
### `.toHaveLastReturnedWith(value)`
299283

300-
Also under the alias: `.lastReturnedWith(value)`
301-
302284
Use `.toHaveLastReturnedWith` to test the specific value that a mock function last returned. If the last call to the mock function threw an error, then this matcher will fail no matter what value you provided as the expected return value.
303285

304286
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
@@ -318,8 +300,6 @@ test('drink returns La Croix (Orange) last', () => {
318300

319301
### `.toHaveNthReturnedWith(nthCall, value)`
320302

321-
Also under the alias: `.nthReturnedWith(nthCall, value)`
322-
323303
Use `.toHaveNthReturnedWith` to test the specific value that a mock function returned for the nth call. If the nth call to the mock function threw an error, then this matcher will fail no matter what value you provided as the expected return value.
324304

325305
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
@@ -782,8 +762,6 @@ describe('the La Croix cans on my desk', () => {
782762

783763
### `.toThrow(error?)`
784764

785-
Also under the alias: `.toThrowError(error?)`
786-
787765
Use `.toThrow` to test that a function throws when it is called. For example, if we want to test that `drinkFlavor('octopus')` throws, because octopus flavor is too disgusting to drink, we could write:
788766

789767
```js

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;

e2e/Utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import * as path from 'path';
99
import * as util from 'util';
1010
import dedent from 'dedent';
1111
import {
12-
ExecaSyncError,
13-
SyncOptions as ExecaSyncOptions,
14-
ExecaSyncReturnValue,
12+
type ExecaSyncError,
13+
type SyncOptions as ExecaSyncOptions,
14+
type ExecaSyncReturnValue,
1515
sync as spawnSync,
1616
} from 'execa';
1717
import * as fs from 'graceful-fs';

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ exports[`moduleNameMapper wrong array configuration 1`] = `
4141
12 | module.exports = () => 'test';
4242
13 |
4343
44-
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1175:17)
44+
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1172:17)
4545
at Object.require (index.js:10:1)
4646
at Object.require (__tests__/index.js:10:20)"
4747
`;
@@ -71,7 +71,7 @@ exports[`moduleNameMapper wrong configuration 1`] = `
7171
12 | module.exports = () => 'test';
7272
13 |
7373
74-
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1175:17)
74+
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1172:17)
7575
at Object.require (index.js:10:1)
7676
at Object.require (__tests__/index.js:10:20)"
7777
`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exports[`shows a proper error from deep requires 1`] = `
2626
12 | test('dummy', () => {
2727
13 | expect(1).toBe(1);
2828
29-
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:930:11)
29+
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:927:11)
3030
at Object.<anonymous> (node_modules/discord.js/src/index.js:21:12)
3131
at Object.require (__tests__/test.js:10:1)"
3232
`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ exports[`show error message with matching files 1`] = `
3737
| ^
3838
9 |
3939
40-
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:930:11)
40+
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:927:11)
4141
at Object.require (index.js:8:18)
4242
at Object.require (__tests__/test.js:8:11)"
4343
`;

e2e/__tests__/env.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import runJest, {RunJestResult} from '../runJest';
8+
import runJest, {type RunJestResult} from '../runJest';
99

1010
const getLog = (result: RunJestResult) => result.stdout.split('\n')[1].trim();
1111

e2e/__tests__/isolateModules.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('works with mocks', () => {
4545
require("./read");
4646
});
4747
48-
expect(configGetMock).toBeCalledTimes(1);
48+
expect(configGetMock).toHaveBeenCalledTimes(1);
4949
})
5050
`,
5151
});

0 commit comments

Comments
 (0)