Skip to content

Commit 1cd0e9e

Browse files
authored
Merge branch 'main' into update/validation
2 parents c70ab34 + 22029ba commit 1cd0e9e

File tree

44 files changed

+1076
-1113
lines changed

Some content is hidden

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

44 files changed

+1076
-1113
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ module.exports = {
226226
'unicorn/no-static-only-class': 'off',
227227
'unicorn/prefer-number-properties': 'off',
228228
'unicorn/prefer-string-raw': 'off',
229+
'unicorn/prefer-global-this': 'off',
229230
},
230231
},
231232
// demonstration of matchers usage

.yarn/releases/yarn-3.8.4.cjs renamed to .yarn/releases/yarn-3.8.6.cjs

Lines changed: 133 additions & 133 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ plugins:
3333
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
3434
spec: "@yarnpkg/plugin-workspace-tools"
3535

36-
yarnPath: .yarn/releases/yarn-3.8.4.cjs
36+
yarnPath: .yarn/releases/yarn-3.8.6.cjs

docs/CLI.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ jest --seed=1324
407407

408408
If this option is not specified Jest will randomly generate the value. You can use the [`--showSeed`](#--showseed) flag to print the seed in the test report summary.
409409

410+
Jest uses the seed internally for shuffling the order in which test suites are run. If the [`--randomize`](#--randomize) option is used, the seed is also used for shuffling the order of tests within each `describe` block. When dealing with flaky tests, rerunning with the same seed might help reproduce the failure.
411+
410412
:::
411413

412414
### `--selectProjects <project1> ... <projectN>`

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`
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)
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`
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)
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`
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)
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`
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)
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`
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)
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

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ exports[`Wrong globals for environment on node <=18 print useful error for navig
1313
1414
ReferenceError: navigator is not defined
1515
16-
30 |
17-
31 | test('use navigator', () => {
18-
> 32 | const userAgent = navigator.userAgent;
16+
31 |
17+
32 | test('use navigator', () => {
18+
> 33 | const userAgent = navigator.userAgent;
1919
| ^
20-
33 |
21-
34 | console.log(userAgent);
22-
35 |
20+
34 |
21+
35 | console.log(userAgent);
22+
36 |
2323
24-
at Object.navigator (__tests__/node.js:32:21)"
24+
at Object.navigator (__tests__/node.js:33:21)"
2525
`;
2626
2727
exports[`Wrong globals for environment print useful error for document 1`] = `
@@ -83,15 +83,15 @@ exports[`Wrong globals for environment print useful error for window 1`] = `
8383
8484
ReferenceError: window is not defined
8585
86-
22 |
8786
23 | test('use window', () => {
88-
> 24 | const location = window.location;
87+
24 | // eslint-disable-next-line unicorn/prefer-global-this
88+
> 25 | const location = window.location;
8989
| ^
90-
25 |
91-
26 | console.log(location);
92-
27 |
90+
26 |
91+
27 | console.log(location);
92+
28 |
9393
94-
at Object.window (__tests__/node.js:24:20)"
94+
at Object.window (__tests__/node.js:25:20)"
9595
`;
9696
9797
exports[`Wrong globals for environment print useful error when it explodes during evaluation 1`] = `

e2e/console-jsdom/__tests__/console.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ test('can mock console.error calls from jsdom', () => {
3030

3131
function onError(event) {}
3232

33-
window.addEventListener('error', onError);
33+
globalThis.addEventListener('error', onError);
3434
fakeNode.addEventListener(evtType, callCallback, false);
3535
evt.initEvent(evtType, false, false);
3636
fakeNode.dispatchEvent(evt);
37-
window.removeEventListener('error', onError);
37+
globalThis.removeEventListener('error', onError);
3838

3939
expect(console.error).toHaveBeenCalledTimes(1);
4040
expect(console.error).toHaveBeenCalledWith(

e2e/env-test/__tests__/equivalent.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
const {isArrayBuffer} = require('util').types;
1010
const isJSDOM =
11+
// eslint-disable-next-line unicorn/prefer-global-this
1112
typeof window !== 'undefined' && typeof document !== 'undefined';
1213

1314
const skipTestJSDOM = isJSDOM ? test.skip : test;

e2e/environmentOptions/__tests__/environmentOptions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
/*eslint-env browser */
99

1010
test('found url jestjs.io', () => {
11-
expect(window.location.href).toBe('https://jestjs.io/');
11+
expect(globalThis.location.href).toBe('https://jestjs.io/');
1212
});

e2e/fake-timers/do-not-fake/__tests__/doNotFake.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
'use strict';
1111

1212
const mockPerformanceMark = jest.fn();
13-
window.performance.mark = mockPerformanceMark;
13+
globalThis.performance.mark = mockPerformanceMark;
1414

1515
test('fakes all APIs', () => {
1616
jest.useFakeTimers();
1717

18-
expect(window.performance.mark).toBeUndefined();
18+
expect(globalThis.performance.mark).toBeUndefined();
1919
});
2020

2121
test('does not fake `performance` instance', () => {
2222
jest.useFakeTimers({doNotFake: ['performance']});
2323

24-
expect(window.performance.mark).toBe(mockPerformanceMark);
24+
expect(globalThis.performance.mark).toBe(mockPerformanceMark);
2525
});

0 commit comments

Comments
 (0)