Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ca3578

Browse files
committed
Merge branch 'main' into v8-coverage-perf
2 parents f7996e7 + 3c31dd6 commit 7ca3578

File tree

54 files changed

+218
-151
lines changed

Some content is hidden

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

54 files changed

+218
-151
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ module.exports = {
333333
parserOptions: {
334334
sourceType: 'module',
335335
},
336-
plugins: ['import'],
336+
plugins: ['import', 'jsdoc'],
337337
rules: {
338338
'accessor-pairs': ['warn', {setWithoutGet: true}],
339339
'block-scoped-var': 'off',
@@ -390,6 +390,7 @@ module.exports = {
390390
},
391391
],
392392
'init-declarations': 'off',
393+
'jsdoc/check-alignment': 'error',
393394
'lines-around-comment': 'off',
394395
'max-depth': 'off',
395396
'max-nested-callbacks': 'off',

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@
1010

1111
- `[jest-runner]` Do not instrument v8 coverage data if coverage should not be collected [#13282](https://github.com/facebook/jest/pull/13282)
1212

13+
## 29.1.2
14+
15+
### Fixes
16+
17+
- `[expect, @jest/expect]` Revert buggy inference of argument types for `*CalledWith` and `*ReturnedWith` matchers introduced in 29.1.0 ([#13339](https://github.com/facebook/jest/pull/13339))
18+
- `[jest-worker]` Add missing dependency on `jest-util` ([#13341](https://github.com/facebook/jest/pull/13341))
19+
1320
## 29.1.1
1421

1522
### Fixes
1623

17-
- `[jest-mock]` Revert ([#13145](https://github.com/facebook/jest/pull/13145))
24+
- `[jest-mock]` Revert [#13145](https://github.com/facebook/jest/pull/13145) which broke mocking of transpiled ES modules
1825

1926
## 29.1.0
2027

2128
### Features
2229

23-
- `[expect, @jest/expect]` support type inference for function parameters in `CalledWith` assertions ([#13268](https://github.com/facebook/jest/pull/13268))
30+
- `[expect, @jest/expect]` Support type inference for function parameters in `CalledWith` assertions ([#13268](https://github.com/facebook/jest/pull/13268))
2431
- `[expect, @jest/expect]` Infer type of `*ReturnedWith` matchers argument ([#13278](https://github.com/facebook/jest/pull/13278))
2532
- `[@jest/environment, jest-runtime]` Allow `jest.requireActual` and `jest.requireMock` to take a type argument ([#13253](https://github.com/facebook/jest/pull/13253))
2633
- `[@jest/environment]` Allow `jest.mock` and `jest.doMock` to take a type argument ([#13254](https://github.com/facebook/jest/pull/13254))

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"syncWorkspaceLock": true
99
}
1010
},
11-
"version": "29.1.1"
11+
"version": "29.1.2"
1212
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"eslint-plugin-eslint-comments": "^3.1.2",
3939
"eslint-plugin-import": "^2.6.0",
4040
"eslint-plugin-jest": "^26.1.0",
41+
"eslint-plugin-jsdoc": "^39.3.6",
4142
"eslint-plugin-local": "^1.0.0",
4243
"eslint-plugin-markdown": "^3.0.0",
4344
"eslint-plugin-prettier": "^4.0.0",

packages/babel-jest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "babel-jest",
33
"description": "Jest plugin to use babel for transformation.",
4-
"version": "29.1.0",
4+
"version": "29.1.2",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/jest.git",

packages/expect-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jest/expect-utils",
3-
"version": "29.1.0",
3+
"version": "29.1.2",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/facebook/jest.git",

packages/expect/__typetests__/expect.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import {
1616
} from 'expect';
1717
import type * as jestMatcherUtils from 'jest-matcher-utils';
1818

19-
type M = Matchers<void, unknown>;
20-
type N = Matchers<void>;
19+
type M = Matchers<void>;
2120

2221
expectError(() => {
2322
type E = Matchers;

packages/expect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "expect",
3-
"version": "29.1.0",
3+
"version": "29.1.2",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/facebook/jest.git",

packages/expect/src/types.ts

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ export interface BaseExpect {
9494
}
9595

9696
export type Expect = {
97-
<T = unknown>(actual: T): Matchers<void, T> &
98-
Inverse<Matchers<void, T>> &
99-
PromiseMatchers<T>;
97+
<T = unknown>(actual: T): Matchers<void> &
98+
Inverse<Matchers<void>> &
99+
PromiseMatchers;
100100
} & BaseExpect &
101101
AsymmetricMatchers &
102102
Inverse<Omit<AsymmetricMatchers, 'any' | 'anything'>>;
@@ -118,38 +118,36 @@ export interface AsymmetricMatchers {
118118
stringMatching(sample: string | RegExp): AsymmetricMatcher;
119119
}
120120

121-
type PromiseMatchers<T = unknown> = {
121+
type PromiseMatchers = {
122122
/**
123123
* Unwraps the reason of a rejected promise so any other matcher can be chained.
124124
* If the promise is fulfilled the assertion fails.
125125
*/
126-
rejects: Matchers<Promise<void>> & Inverse<Matchers<Promise<void>, T>>;
126+
rejects: Matchers<Promise<void>> & Inverse<Matchers<Promise<void>>>;
127127
/**
128128
* Unwraps the value of a fulfilled promise so any other matcher can be chained.
129129
* If the promise is rejected the assertion fails.
130130
*/
131-
resolves: Matchers<Promise<void>> & Inverse<Matchers<Promise<void>, T>>;
131+
resolves: Matchers<Promise<void>> & Inverse<Matchers<Promise<void>>>;
132132
};
133133

134-
type EnsureFunctionLike<T> = T extends (...args: any) => any ? T : never;
135-
136-
export interface Matchers<R extends void | Promise<void>, T = unknown> {
134+
export interface Matchers<R extends void | Promise<void>> {
137135
/**
138136
* Ensures the last call to a mock function was provided specific args.
139137
*/
140-
lastCalledWith(...expected: Parameters<EnsureFunctionLike<T>>): R;
138+
lastCalledWith(...expected: Array<unknown>): R;
141139
/**
142140
* Ensure that the last call to a mock function has returned a specified value.
143141
*/
144-
lastReturnedWith(expected: ReturnType<EnsureFunctionLike<T>>): R;
142+
lastReturnedWith(expected: unknown): R;
145143
/**
146144
* Ensure that a mock function is called with specific arguments on an Nth call.
147145
*/
148-
nthCalledWith(nth: number, ...expected: Parameters<EnsureFunctionLike<T>>): R;
146+
nthCalledWith(nth: number, ...expected: Array<unknown>): R;
149147
/**
150148
* Ensure that the nth call to a mock function has returned a specified value.
151149
*/
152-
nthReturnedWith(nth: number, expected: ReturnType<EnsureFunctionLike<T>>): R;
150+
nthReturnedWith(nth: number, expected: unknown): R;
153151
/**
154152
* Checks that a value is what you expect. It calls `Object.is` to compare values.
155153
* Don't use `toBe` with floating-point numbers.
@@ -166,7 +164,7 @@ export interface Matchers<R extends void | Promise<void>, T = unknown> {
166164
/**
167165
* Ensure that a mock function is called with specific arguments.
168166
*/
169-
toBeCalledWith(...expected: Parameters<EnsureFunctionLike<T>>): R;
167+
toBeCalledWith(...expected: Array<unknown>): R;
170168
/**
171169
* Using exact equality with floating point numbers is a bad idea.
172170
* Rounding means that intuitive things fail.
@@ -249,25 +247,22 @@ export interface Matchers<R extends void | Promise<void>, T = unknown> {
249247
/**
250248
* Ensure that a mock function is called with specific arguments.
251249
*/
252-
toHaveBeenCalledWith(...expected: Parameters<EnsureFunctionLike<T>>): R;
250+
toHaveBeenCalledWith(...expected: Array<unknown>): R;
253251
/**
254252
* Ensure that a mock function is called with specific arguments on an Nth call.
255253
*/
256-
toHaveBeenNthCalledWith(
257-
nth: number,
258-
...expected: Parameters<EnsureFunctionLike<T>>
259-
): R;
254+
toHaveBeenNthCalledWith(nth: number, ...expected: Array<unknown>): R;
260255
/**
261256
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
262257
* to test what arguments it was last called with.
263258
*/
264-
toHaveBeenLastCalledWith(...expected: Parameters<EnsureFunctionLike<T>>): R;
259+
toHaveBeenLastCalledWith(...expected: Array<unknown>): R;
265260
/**
266261
* Use to test the specific value that a mock function last returned.
267262
* If the last call to the mock function threw an error, then this matcher will fail
268263
* no matter what value you provided as the expected return value.
269264
*/
270-
toHaveLastReturnedWith(expected: ReturnType<EnsureFunctionLike<T>>): R;
265+
toHaveLastReturnedWith(expected: unknown): R;
271266
/**
272267
* Used to check that an object has a `.length` property
273268
* and it is set to a certain numeric value.
@@ -278,10 +273,7 @@ export interface Matchers<R extends void | Promise<void>, T = unknown> {
278273
* If the nth call to the mock function threw an error, then this matcher will fail
279274
* no matter what value you provided as the expected return value.
280275
*/
281-
toHaveNthReturnedWith(
282-
nth: number,
283-
expected: ReturnType<EnsureFunctionLike<T>>,
284-
): R;
276+
toHaveNthReturnedWith(nth: number, expected: unknown): R;
285277
/**
286278
* Use to check if property at provided reference keyPath exists for an object.
287279
* For checking deeply nested properties in an object you may use dot notation or an array containing
@@ -311,7 +303,7 @@ export interface Matchers<R extends void | Promise<void>, T = unknown> {
311303
/**
312304
* Use to ensure that a mock function returned a specific value.
313305
*/
314-
toHaveReturnedWith(expected: ReturnType<EnsureFunctionLike<T>>): R;
306+
toHaveReturnedWith(expected: unknown): R;
315307
/**
316308
* Check that a string matches a regular expression.
317309
*/
@@ -333,7 +325,7 @@ export interface Matchers<R extends void | Promise<void>, T = unknown> {
333325
/**
334326
* Ensure that a mock function has returned a specified value at least once.
335327
*/
336-
toReturnWith(expected: ReturnType<EnsureFunctionLike<T>>): R;
328+
toReturnWith(expected: unknown): R;
337329
/**
338330
* Use to test that objects have the same types as well as structure.
339331
*/

packages/jest-circus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jest-circus",
3-
"version": "29.1.1",
3+
"version": "29.1.2",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/facebook/jest.git",

0 commit comments

Comments
 (0)