Skip to content

Commit f3888ef

Browse files
committed
Merge remote-tracking branch 'origin/jest-on-mock-hook' into jest-on-mock-hook
2 parents 9d65bc5 + 583453c commit f3888ef

File tree

25 files changed

+243
-198
lines changed

25 files changed

+243
-198
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
- [**BREAKING**] `--testPathPattern` is now `--testPathPatterns`
8787
- [**BREAKING**] Specifying `testPathPatterns` when programmatically calling `watch` must be specified as `new TestPathPatterns(patterns)`, where `TestPathPatterns` can be imported from `@jest/pattern`
8888
- `[jest-reporters, jest-runner]` Unhandled errors without stack get correctly logged to console ([#14619](https://github.com/jestjs/jest/pull/14619))
89+
- `[jest-util]` Always load `mjs` files with `import` ([#15447](https://github.com/jestjs/jest/pull/15447))
8990
- `[jest-worker]` Properly handle a circular reference error when worker tries to send an assertion fails where either the expected or actual value is circular ([#15191](https://github.com/jestjs/jest/pull/15191))
9091
- `[jest-worker]` Properly handle a BigInt when worker tries to send an assertion fails where either the expected or actual value is BigInt ([#15191](https://github.com/jestjs/jest/pull/15191))
9192

@@ -122,6 +123,7 @@
122123
- `[docs]` Link NestJS documentation on testing with Jest ([#14940](https://github.com/jestjs/jest/pull/14940))
123124
- `[docs]` `Revised documentation for .toHaveBeenCalled()` to accurately depict its functionality. ([#14853](https://github.com/jestjs/jest/pull/14853))
124125
- `[docs]` Removed ExpressJS reference link from documentation due to dead link ([#15270](https://github.com/jestjs/jest/pull/15270))
126+
- `[docs]` Removed `Running AngularJS Tests with Jest reference` link from documentation due to dead link ([#15270](https://github.com/jestjs/jest/pull/15311))
125127

126128
## 29.7.0
127129

docs/GlobalAPI.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Use `describe.each` if you keep duplicating the same test suites with different
251251
- `%$` - Number of the test case.
252252
- `%%` - single percent sign ('%'). This does not consume an argument.
253253
- Or generate unique test titles by injecting properties of test case object with `$variable`
254-
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properites](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
254+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
255255
- You can use `$#` to inject the index of the test case
256256
- You cannot use `$variable` with the `printf` formatting except for `%%`
257257
- `fn`: `Function` the suite of tests to be run, this is the function that will receive the parameters in each row as function arguments.
@@ -305,7 +305,7 @@ describe.each([
305305
- First row of variable name column headings separated with `|`
306306
- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax.
307307
- `name`: `String` the title of the test suite, use `$variable` to inject test data into the suite title from the tagged template expressions, and `$#` for the index of the row.
308-
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properites](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
308+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
309309
- `fn`: `Function` the suite of tests to be run, this is the function that will receive the test data object.
310310
- Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait for each row before aborting. The default timeout is 5 seconds.
311311

@@ -574,7 +574,7 @@ test.concurrent.each([
574574
- First row of variable name column headings separated with `|`
575575
- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax.
576576
- `name`: `String` the title of the test, use `$variable` to inject test data into the test title from the tagged template expressions.
577-
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properites](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
577+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
578578
- `fn`: `Function` the test to be run, this is the function that will receive the test data object, **this will have to be an asynchronous function**.
579579
- Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait for each row before aborting. The default timeout is 5 seconds.
580580

@@ -697,7 +697,7 @@ Use `test.each` if you keep duplicating the same test with different data. `test
697697
- `%$` - Number of the test case.
698698
- `%%` - single percent sign ('%'). This does not consume an argument.
699699
- Or generate unique test titles by injecting properties of test case object with `$variable`
700-
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properites](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
700+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
701701
- You can use `$#` to inject the index of the test case
702702
- You cannot use `$variable` with the `printf` formatting except for `%%`
703703
- `fn`: `Function` the test to be run, this is the function that will receive the parameters in each row as function arguments.
@@ -731,7 +731,7 @@ test.each([
731731
- First row of variable name column headings separated with `|`
732732
- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax.
733733
- `name`: `String` the title of the test, use `$variable` to inject test data into the test title from the tagged template expressions.
734-
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properites](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
734+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for ["own" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)
735735
- `fn`: `Function` the test to be run, this is the function that will receive the test data object.
736736
- Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait for each row before aborting. The default timeout is 5 seconds.
737737

docs/TestingFrameworks.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Jest is a universal testing platform, with the ability to adapt to any JavaScrip
1717
## AngularJS
1818

1919
- [Testing an AngularJS app with Jest](https://medium.com/aya-experience/testing-an-angularjs-app-with-jest-3029a613251) by Matthieu Lux ([@Swiip](https://twitter.com/Swiip))
20-
- [Running AngularJS Tests with Jest](https://engineering.talentpair.com/running-angularjs-tests-with-jest-49d0cc9c6d26) by Ben Brandt ([@benjaminbrandt](https://twitter.com/benjaminbrandt))
2120
- [AngularJS Unit Tests with Jest Actions (Traditional Chinese)](https://dwatow.github.io/2019/08-14-angularjs/angular-jest/?fbclid=IwAR2SrqYg_o6uvCQ79FdNPeOxs86dUqB6pPKgd9BgnHt1kuIDRyRM-ch11xg) by Chris Wang ([@dwatow](https://github.com/dwatow))
2221

2322
## Angular

e2e/esm-config/js/jest.config.js

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

8+
const displayName = await Promise.resolve('Config from js file');
9+
810
export default {
9-
displayName: 'Config from js file',
11+
displayName,
1012
testEnvironment: 'node',
1113
};

e2e/esm-config/mjs/jest.config.mjs

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

8+
const displayName = await Promise.resolve('Config from mjs file');
9+
810
export default {
9-
displayName: 'Config from mjs file',
11+
displayName,
1012
testEnvironment: 'node',
1113
};

e2e/native-esm/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ __metadata:
341341
linkType: hard
342342

343343
"cross-spawn@npm:^7.0.0":
344-
version: 7.0.3
345-
resolution: "cross-spawn@npm:7.0.3"
344+
version: 7.0.6
345+
resolution: "cross-spawn@npm:7.0.6"
346346
dependencies:
347347
path-key: ^3.1.0
348348
shebang-command: ^2.0.0
349349
which: ^2.0.1
350-
checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52
350+
checksum: 8d306efacaf6f3f60e0224c287664093fa9185680b2d195852ba9a863f85d02dcc737094c6e512175f8ee0161f9b87c73c6826034c2422e39de7d6569cf4503b
351351
languageName: node
352352
linkType: hard
353353

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"strip-json-comments": "^3.1.1",
7979
"tempy": "^1.0.0",
8080
"ts-node": "^10.5.0",
81-
"tstyche": "^2.0.0",
81+
"tstyche": "^3.0.0",
8282
"typescript": "^5.0.4",
8383
"webpack": "^5.68.0",
8484
"webpack-node-externals": "^3.0.0",

packages/diff-sequences/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"devDependencies": {
3333
"@fast-check/jest": "^2.0.0",
3434
"benchmark": "^2.1.4",
35-
"diff": "^5.0.0"
35+
"diff": "^7.0.0"
3636
},
3737
"publishConfig": {
3838
"access": "public"

packages/jest-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@types/graceful-fs": "^4.1.3",
6565
"@types/micromatch": "^4.0.7",
6666
"@types/parse-json": "^4.0.0",
67-
"esbuild": "^0.23.0",
67+
"esbuild": "^0.24.0",
6868
"esbuild-register": "^3.4.0",
6969
"semver": "^7.5.3",
7070
"ts-node": "^10.5.0",

packages/jest-config/src/__tests__/normalize.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ jest
2626
...realFs,
2727
statSync: () => ({isDirectory: () => true}),
2828
};
29+
})
30+
.mock('jest-util', () => {
31+
const realUtil =
32+
jest.requireActual<typeof import('jest-util')>('jest-util');
33+
34+
return {
35+
...realUtil,
36+
requireOrImportModule: (filePath: string, interop = true) => {
37+
const result = require(filePath);
38+
39+
if (interop) {
40+
return realUtil.interopRequireDefault(result).default;
41+
}
42+
43+
return result;
44+
},
45+
};
2946
});
3047

3148
let root: string;

0 commit comments

Comments
 (0)