Skip to content

Commit a36c5ed

Browse files
authored
Merge branch 'main' into upgrade-jsdom
2 parents 1d98ae6 + 541586b commit a36c5ed

File tree

119 files changed

+871
-765
lines changed

Some content is hidden

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

119 files changed

+871
-765
lines changed

.eslintrc.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module.exports = {
4242
{
4343
extends: [
4444
'plugin:@typescript-eslint/recommended',
45-
'plugin:@typescript-eslint/eslint-recommended',
4645
'plugin:import/typescript',
4746
],
4847
files: ['*.ts', '*.tsx'],
@@ -64,6 +63,10 @@ module.exports = {
6463
// TODO: enable at some point
6564
'@typescript-eslint/no-explicit-any': 'off',
6665
'@typescript-eslint/no-non-null-assertion': 'off',
66+
67+
// TODO: part of "stylistic" rules, remove explicit activation when that lands
68+
'@typescript-eslint/no-empty-function': 'error',
69+
'@typescript-eslint/no-empty-interface': 'error',
6770
},
6871
},
6972
{
@@ -592,6 +595,7 @@ module.exports = {
592595
yoda: 'off',
593596

594597
'unicorn/explicit-length-check': 'error',
598+
'unicorn/no-array-for-each': 'error',
595599
'unicorn/no-negated-condition': 'error',
596600
'unicorn/prefer-default-parameters': 'error',
597601
'unicorn/prefer-includes': 'error',

.github/workflows/nodejs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,36 @@ jobs:
124124
test-ubuntu:
125125
uses: ./.github/workflows/test.yml
126126
needs: prepare-yarn-cache-ubuntu
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
shard: ['1/4', '2/4', '3/4', '4/4']
131+
name: Ubuntu with shard ${{ matrix.shard }}
127132
with:
128133
os: ubuntu-latest
134+
shard: ${{ matrix.shard }}
129135
test-macos:
130136
uses: ./.github/workflows/test.yml
131137
needs: prepare-yarn-cache-macos
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
shard: ['1/3', '2/3', '3/3']
142+
name: macOS with shard ${{ matrix.shard }}
132143
with:
133144
os: macos-latest
145+
shard: ${{ matrix.shard }}
134146
test-windows:
135147
uses: ./.github/workflows/test.yml
136148
needs: prepare-yarn-cache-windows
149+
strategy:
150+
fail-fast: false
151+
matrix:
152+
shard: ['1/4', '2/4', '3/4', '4/4']
153+
name: Windows with shard ${{ matrix.shard }}
137154
with:
138155
os: windows-latest
156+
shard: ${{ matrix.shard }}
139157

140158
test-leak:
141159
name: Node LTS on Ubuntu with leak detection

.github/workflows/test.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ on:
66
os:
77
required: true
88
type: string
9+
shard:
10+
required: true
11+
type: string
912

1013
jobs:
1114
test:
1215
strategy:
1316
fail-fast: false
1417
matrix:
1518
node-version: [16.x, 18.x, 20.x]
16-
shard: ['1/4', '2/4', '3/4', '4/4']
17-
name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }})
19+
name: Node v${{ matrix.node-version }}
1820
runs-on: ${{ inputs.os }}
1921

2022
steps:
@@ -34,14 +36,10 @@ jobs:
3436
id: cpu-cores
3537
uses: SimenB/github-actions-cpu-cores@v2
3638
- name: run tests
37-
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
39+
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}
3840

3941
test-jasmine:
40-
strategy:
41-
fail-fast: false
42-
matrix:
43-
shard: ['1/4', '2/4', '3/4', '4/4']
44-
name: Node LTS on ${{ inputs.os }} using jest-jasmine2 (${{ matrix.shard }})
42+
name: Node LTS using jest-jasmine2
4543
runs-on: ${{ inputs.os }}
4644

4745
steps:
@@ -61,4 +59,4 @@ jobs:
6159
id: cpu-cores
6260
uses: SimenB/github-actions-cpu-cores@v2
6361
- name: run tests using jest-jasmine
64-
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
62+
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### Features
44

55
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM to v22 ([#13825](https://github.com/jestjs/jest/pull/13825))
6-
- `[jest-test-sequencer, jest-core]` Exposes globalConfig & contexts to TestSequencer ([#14535](https://github.com/jestjs/jest/pull/14535))
6+
- `[@jest/test-sequencer, jest-core]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543))
77

88
### Fixes
99

e2e/MockStdinWatchPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MockStdinWatchPlugin {
2020
apply(jestHooks) {
2121
jestHooks.onTestRunComplete(() => {
2222
const {keys} = this._config.input.shift();
23-
keys.forEach(key => this._stdin.emit('data', key));
23+
for (const key of keys) this._stdin.emit('data', key);
2424
});
2525
}
2626
}

e2e/Utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const writeFiles = (
128128
files: {[filename: string]: string},
129129
) => {
130130
fs.mkdirSync(directory, {recursive: true});
131-
Object.keys(files).forEach(fileOrPath => {
131+
for (const fileOrPath of Object.keys(files)) {
132132
const dirname = path.dirname(fileOrPath);
133133

134134
if (dirname !== '/') {
@@ -138,15 +138,15 @@ export const writeFiles = (
138138
path.resolve(directory, ...fileOrPath.split('/')),
139139
dedent(files[fileOrPath]),
140140
);
141-
});
141+
}
142142
};
143143

144144
export const writeSymlinks = (
145145
directory: string,
146146
symlinks: {[existingFile: string]: string},
147147
) => {
148148
fs.mkdirSync(directory, {recursive: true});
149-
Object.keys(symlinks).forEach(fileOrPath => {
149+
for (const fileOrPath of Object.keys(symlinks)) {
150150
const symLinkPath = symlinks[fileOrPath];
151151
const dirname = path.dirname(symLinkPath);
152152

@@ -158,7 +158,7 @@ export const writeSymlinks = (
158158
path.resolve(directory, ...symLinkPath.split('/')),
159159
'junction',
160160
);
161-
});
161+
}
162162
};
163163

164164
const NUMBER_OF_TESTS_TO_FORCE_USING_WORKERS = 25;

e2e/__tests__/coverageRemapping.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ it('maps code coverage against original source', () => {
2727
const coverageMap = JSON.parse(readFileSync(coverageMapFile, 'utf-8'));
2828

2929
// reduce absolute paths embedded in the coverage map to just filenames
30-
Object.keys(coverageMap).forEach(filename => {
30+
for (const filename of Object.keys(coverageMap)) {
3131
coverageMap[filename].path = path.basename(coverageMap[filename].path);
3232
delete coverageMap[filename].hash;
3333
coverageMap[path.basename(filename)] = coverageMap[filename];
3434
delete coverageMap[filename];
35-
});
35+
}
3636
expect(coverageMap).toMatchSnapshot();
3737
});

e2e/__tests__/coverageTransformInstrumented.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ it('code coverage for transform instrumented code', () => {
2727
const coverageMap = JSON.parse(readFileSync(coverageMapFile, 'utf-8'));
2828

2929
// reduce absolute paths embedded in the coverage map to just filenames
30-
Object.keys(coverageMap).forEach(filename => {
30+
for (const filename of Object.keys(coverageMap)) {
3131
coverageMap[filename].path = path.basename(coverageMap[filename].path);
3232
delete coverageMap[filename].hash;
3333
coverageMap[path.basename(filename)] = coverageMap[filename];
3434
delete coverageMap[filename];
35-
});
35+
}
3636
expect(coverageMap).toMatchSnapshot();
3737
});

e2e/__tests__/errorOnDeprecated.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const SHOULD_NOT_PASS_IN_JEST = new Set([
3131
'spyOnProperty.test.js',
3232
]);
3333

34-
testFiles.forEach(testFile => {
34+
for (const testFile of testFiles) {
3535
test(`${testFile} errors in errorOnDeprecated mode`, () => {
3636
const result = runJest('error-on-deprecated', [
3737
testFile,
@@ -42,9 +42,9 @@ testFiles.forEach(testFile => {
4242

4343
expect(rest).toMatchSnapshot();
4444
});
45-
});
45+
}
4646

47-
testFiles.forEach(testFile => {
47+
for (const testFile of testFiles) {
4848
const shouldPass = SHOULD_NOT_PASS_IN_JEST.has(testFile);
4949

5050
const expectation = `${testFile} ${shouldPass ? 'errors' : 'passes'}`;
@@ -54,4 +54,4 @@ testFiles.forEach(testFile => {
5454
const result = runJest('error-on-deprecated', [testFile]);
5555
expect(result.exitCode).toBe(shouldPass ? 1 : 0);
5656
});
57-
});
57+
}

e2e/__tests__/snapshot.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ const getSnapshotOfCopy = () => {
7070

7171
describe('Snapshot', () => {
7272
const cleanup = () => {
73-
[
73+
for (const file of [
7474
snapshotFile,
7575
secondSnapshotFile,
7676
snapshotOfCopy,
7777
copyOfTestPath,
7878
snapshotEscapeFile,
7979
snapshotEscapeRegexFile,
8080
snapshotEscapeSubstitutionFile,
81-
].forEach(file => {
81+
]) {
8282
if (fileExists(file)) {
8383
fs.unlinkSync(file);
8484
}
85-
});
85+
}
8686
if (fileExists(snapshotDir)) {
8787
fs.rmdirSync(snapshotDir);
8888
}

e2e/__tests__/summaryThreshold.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import runJest from '../runJest';
99

10-
['default', 'summary'].forEach(reporter => {
10+
for (const reporter of ['default', 'summary']) {
1111
describe(`${reporter} reporter`, () => {
1212
test('prints failure messages when total number of test suites is over summaryThreshold', () => {
1313
const {exitCode, stderr} = runJest('summary-threshold', [
@@ -26,4 +26,4 @@ import runJest from '../runJest';
2626
);
2727
});
2828
});
29-
});
29+
}

e2e/__tests__/transform.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ describe('transformer caching', () => {
199199
const loggedFiles = stdout.split('\n');
200200

201201
// Verify any lines logged are _just_ the file we care about
202-
loggedFiles.forEach(line => {
202+
for (const line of loggedFiles) {
203203
expect(line).toBe(transformedFile);
204-
});
204+
}
205205

206206
// We run with 2 workers, so the file should be transformed twice
207207
expect(loggedFiles).toHaveLength(2);

e2e/__tests__/watchModeOnlyFailed.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ test('can press "f" to run only failed tests', () => {
4141
const results = extractSummaries(stderr);
4242

4343
expect(results).toHaveLength(2);
44-
results.forEach(({rest, summary}) => {
44+
for (const {rest, summary} of results) {
4545
expect(rest).toMatchSnapshot('test results');
4646
expect(summary).toMatchSnapshot('test summary');
47-
});
47+
}
4848
expect(exitCode).toBe(0);
4949
});

e2e/__tests__/watchModePatterns.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ test('can press "p" to filter by file name', () => {
4747

4848
expect(stdout).toMatchSnapshot();
4949
expect(results).toHaveLength(2);
50-
results.forEach(({rest, summary}) => {
50+
for (const {rest, summary} of results) {
5151
expect(rest).toMatchSnapshot('test results');
5252
expect(summary).toMatchSnapshot('test summary');
53-
});
53+
}
5454
expect(exitCode).toBe(0);
5555
});
5656

@@ -66,9 +66,9 @@ test('can press "t" to filter by test name', () => {
6666

6767
expect(stdout).toMatchSnapshot();
6868
expect(results).toHaveLength(2);
69-
results.forEach(({rest, summary}) => {
69+
for (const {rest, summary} of results) {
7070
expect(rest).toMatchSnapshot('test results');
7171
expect(summary).toMatchSnapshot('test summary');
72-
});
72+
}
7373
expect(exitCode).toBe(0);
7474
});

e2e/__tests__/watchModeUpdateSnapshot.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ test('can press "u" to update snapshots', () => {
4646
const {exitCode, stderr} = runJest(DIR, ['--no-watchman', '--watchAll']);
4747
const results = extractSummaries(stderr);
4848
expect(results).toHaveLength(2);
49-
results.forEach(({rest, summary}) => {
49+
for (const {rest, summary} of results) {
5050
expect(rest).toMatchSnapshot('test results');
5151
expect(summary).toMatchSnapshot('test summary');
52-
});
52+
}
5353
expect(exitCode).toBe(0);
5454
});

e2e/custom-reporters/reporters/AssertionCountsReporter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
class AssertionCountsReporter {
1111
onTestFileResult(test, testResult, aggregatedResult) {
12-
testResult.testResults.forEach((testCaseResult, index) => {
12+
for (const [index, testCaseResult] of testResult.testResults.entries()) {
1313
console.log(
1414
`onTestFileResult testCaseResult ${index}: ${testCaseResult.title}, ` +
1515
`status: ${testCaseResult.status}, ` +
1616
`numExpectations: ${testCaseResult.numPassingAsserts}`,
1717
);
18-
});
18+
}
1919
}
2020
onTestCaseResult(test, testCaseResult) {
2121
console.log(

e2e/jasmine-async/__tests__/returningValues.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'use strict';
99

1010
describe('returning values', () => {
11-
[
11+
for (const val of [
1212
1,
1313
'string',
1414
0.1,
@@ -20,7 +20,7 @@ describe('returning values', () => {
2020
[1],
2121
{},
2222
() => {},
23-
].forEach(val => {
23+
]) {
2424
it(`throws if '${val}:${typeof val}' is returned`, () => val);
25-
});
25+
}
2626
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"@types/node": "^16.10.0",
2323
"@types/which": "^3.0.0",
2424
"@types/ws": "8.5.1",
25-
"@typescript-eslint/eslint-plugin": "^5.14.0",
26-
"@typescript-eslint/parser": "^5.14.0",
25+
"@typescript-eslint/eslint-plugin": "^6.6.0",
26+
"@typescript-eslint/parser": "^6.6.0",
2727
"ansi-regex": "^5.0.1",
2828
"ansi-styles": "^5.0.0",
2929
"babel-jest": "workspace:^",

packages/diff-sequences/__benchmarks__/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ const testLength = n => {
142142

143143
writeHeading3(n);
144144

145-
[2, 4, 8].forEach(tenth => {
145+
for (const tenth of [2, 4, 8]) {
146146
testDeleteInsert(
147147
tenth,
148148
all,
149149
getItems(n, i => i % 10 >= tenth && `${i}`),
150150
);
151-
});
151+
}
152152
testChange(
153153
1,
154154
all,

0 commit comments

Comments
 (0)