Skip to content

Commit

Permalink
Merge branch 'main' into improve-detect
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Sep 19, 2023
2 parents b0d7c51 + e9ec62d commit f827305
Show file tree
Hide file tree
Showing 151 changed files with 1,077 additions and 1,093 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = {
{
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/typescript',
],
files: ['*.ts', '*.tsx'],
Expand All @@ -64,6 +63,10 @@ module.exports = {
// TODO: enable at some point
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',

// TODO: part of "stylistic" rules, remove explicit activation when that lands
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
},
},
{
Expand Down Expand Up @@ -592,6 +595,7 @@ module.exports = {
yoda: 'off',

'unicorn/explicit-length-check': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/no-negated-condition': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-includes': 'error',
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: yarn test-ts --selectProjects ts-integration
- name: type tests
run: yarn test-ts --selectProjects type-tests
- name: verify TypeScript@4.3 compatibility
- name: verify TypeScript@5.0 compatibility
run: yarn verify-old-ts
- name: run ESLint with type info
run: yarn lint-ts-files
Expand Down Expand Up @@ -124,18 +124,36 @@ jobs:
test-ubuntu:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-ubuntu
strategy:
fail-fast: false
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
name: Ubuntu with shard ${{ matrix.shard }}
with:
os: ubuntu-latest
shard: ${{ matrix.shard }}
test-macos:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-macos
strategy:
fail-fast: false
matrix:
shard: ['1/3', '2/3', '3/3']
name: macOS with shard ${{ matrix.shard }}
with:
os: macos-latest
shard: ${{ matrix.shard }}
test-windows:
uses: ./.github/workflows/test.yml
needs: prepare-yarn-cache-windows
strategy:
fail-fast: false
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
name: Windows with shard ${{ matrix.shard }}
with:
os: windows-latest
shard: ${{ matrix.shard }}

test-leak:
name: Node LTS on Ubuntu with leak detection
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ on:
os:
required: true
type: string
shard:
required: true
type: string

jobs:
test:
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x]
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }})
name: Node v${{ matrix.node-version }}
runs-on: ${{ inputs.os }}

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

test-jasmine:
strategy:
fail-fast: false
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node LTS on ${{ inputs.os }} using jest-jasmine2 (${{ matrix.shard }})
name: Node LTS using jest-jasmine2
runs-on: ${{ inputs.os }}

steps:
Expand All @@ -61,4 +59,4 @@ jobs:
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v2
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- `[@jest/core]` [**BREAKING**] Group together open handles with the same stack trace ([#13417](https://github.com/jestjs/jest/pull/13417), & [#14543](https://github.com/jestjs/jest/pull/14543))
- `[@jest/core, @jest/test-sequencer]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543))
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM to v22 ([#13825](https://github.com/jestjs/jest/pull/13825))
- `[@jest/fake-timers]` [**BREAKING**] Upgrade `@sinonjs/fake-timers` to v11 ([#14544](https://github.com/jestjs/jest/pull/14544))
- `[pretty-format]` [**BREAKING**] Do not render empty string children (`''`) in React plugin ([#14470](https://github.com/facebook/jest/pull/14470))

### Fixes

Expand All @@ -14,6 +17,8 @@
### Chore & Maintenance

- `[*]` [**BREAKING**] Drop support for Node.js versions 14 and 19 ([#14460](https://github.com/jestjs/jest/pull/14460))
- `[*]` [**BREAKING**] Drop support for `typescript@4.3`, minimum version is now `5.0` ([#14542](https://github.com/facebook/jest/pull/14542), [#12648](https://github.com/facebook/jest/pull/12648))
- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490))

## 29.7.0

Expand Down
4 changes: 0 additions & 4 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, DependencyRange2, Depende
DependencyType2 \= 'peerDependencies',
% A list of exception to same version rule
\+ member(DependencyIdent, [
% Allow enzyme example workspace use a older version react and react-dom, because enzyme don't support react 17
'react', 'react-dom', '@types/react',
% Only RN should be bumped to react 18
'react-test-renderer',
% @types/node in the root need to stay on ~14.14.45
'@types/node',
% upgrading the entire repository is a breaking change
Expand Down
4 changes: 0 additions & 4 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ Show the help information, similar to this page.

Ignore the tests of the specified projects. Jest uses the attribute `displayName` in the configuration to identify each project. If you use this option, you should provide a `displayName` to all your projects.

### `--init`

Generate a basic configuration file. Based on your project, Jest will ask you a few questions that will help to generate a `jest.config.js` file with a short description for each option.

### `--injectGlobals`

Insert Jest's globals (`expect`, `test`, `describe`, `beforeEach` etc.) into the global environment. If you set this to `false`, you should import from `@jest/globals`, e.g.
Expand Down
2 changes: 1 addition & 1 deletion e2e/MockStdinWatchPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MockStdinWatchPlugin {
apply(jestHooks) {
jestHooks.onTestRunComplete(() => {
const {keys} = this._config.input.shift();
keys.forEach(key => this._stdin.emit('data', key));
for (const key of keys) this._stdin.emit('data', key);
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const writeFiles = (
files: {[filename: string]: string},
) => {
fs.mkdirSync(directory, {recursive: true});
Object.keys(files).forEach(fileOrPath => {
for (const fileOrPath of Object.keys(files)) {
const dirname = path.dirname(fileOrPath);

if (dirname !== '/') {
Expand All @@ -138,15 +138,15 @@ export const writeFiles = (
path.resolve(directory, ...fileOrPath.split('/')),
dedent(files[fileOrPath]),
);
});
}
};

export const writeSymlinks = (
directory: string,
symlinks: {[existingFile: string]: string},
) => {
fs.mkdirSync(directory, {recursive: true});
Object.keys(symlinks).forEach(fileOrPath => {
for (const fileOrPath of Object.keys(symlinks)) {
const symLinkPath = symlinks[fileOrPath];
const dirname = path.dirname(symLinkPath);

Expand All @@ -158,7 +158,7 @@ export const writeSymlinks = (
path.resolve(directory, ...symLinkPath.split('/')),
'junction',
);
});
}
};

const NUMBER_OF_TESTS_TO_FORCE_USING_WORKERS = 25;
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/coverageRemapping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ it('maps code coverage against original source', () => {
const coverageMap = JSON.parse(readFileSync(coverageMapFile, 'utf-8'));

// reduce absolute paths embedded in the coverage map to just filenames
Object.keys(coverageMap).forEach(filename => {
for (const filename of Object.keys(coverageMap)) {
coverageMap[filename].path = path.basename(coverageMap[filename].path);
delete coverageMap[filename].hash;
coverageMap[path.basename(filename)] = coverageMap[filename];
delete coverageMap[filename];
});
}
expect(coverageMap).toMatchSnapshot();
});
4 changes: 2 additions & 2 deletions e2e/__tests__/coverageTransformInstrumented.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ it('code coverage for transform instrumented code', () => {
const coverageMap = JSON.parse(readFileSync(coverageMapFile, 'utf-8'));

// reduce absolute paths embedded in the coverage map to just filenames
Object.keys(coverageMap).forEach(filename => {
for (const filename of Object.keys(coverageMap)) {
coverageMap[filename].path = path.basename(coverageMap[filename].path);
delete coverageMap[filename].hash;
coverageMap[path.basename(filename)] = coverageMap[filename];
delete coverageMap[filename];
});
}
expect(coverageMap).toMatchSnapshot();
});
8 changes: 4 additions & 4 deletions e2e/__tests__/errorOnDeprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const SHOULD_NOT_PASS_IN_JEST = new Set([
'spyOnProperty.test.js',
]);

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

expect(rest).toMatchSnapshot();
});
});
}

testFiles.forEach(testFile => {
for (const testFile of testFiles) {
const shouldPass = SHOULD_NOT_PASS_IN_JEST.has(testFile);

const expectation = `${testFile} ${shouldPass ? 'errors' : 'passes'}`;
Expand All @@ -54,4 +54,4 @@ testFiles.forEach(testFile => {
const result = runJest('error-on-deprecated', [testFile]);
expect(result.exitCode).toBe(shouldPass ? 1 : 0);
});
});
}
6 changes: 3 additions & 3 deletions e2e/__tests__/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ const getSnapshotOfCopy = () => {

describe('Snapshot', () => {
const cleanup = () => {
[
for (const file of [
snapshotFile,
secondSnapshotFile,
snapshotOfCopy,
copyOfTestPath,
snapshotEscapeFile,
snapshotEscapeRegexFile,
snapshotEscapeSubstitutionFile,
].forEach(file => {
]) {
if (fileExists(file)) {
fs.unlinkSync(file);
}
});
}
if (fileExists(snapshotDir)) {
fs.rmdirSync(snapshotDir);
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/summaryThreshold.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import runJest from '../runJest';

['default', 'summary'].forEach(reporter => {
for (const reporter of ['default', 'summary']) {
describe(`${reporter} reporter`, () => {
test('prints failure messages when total number of test suites is over summaryThreshold', () => {
const {exitCode, stderr} = runJest('summary-threshold', [
Expand All @@ -26,4 +26,4 @@ import runJest from '../runJest';
);
});
});
});
}
4 changes: 2 additions & 2 deletions e2e/__tests__/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ describe('transformer caching', () => {
const loggedFiles = stdout.split('\n');

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

// We run with 2 workers, so the file should be transformed twice
expect(loggedFiles).toHaveLength(2);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/watchModeOnlyFailed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ test('can press "f" to run only failed tests', () => {
const results = extractSummaries(stderr);

expect(results).toHaveLength(2);
results.forEach(({rest, summary}) => {
for (const {rest, summary} of results) {
expect(rest).toMatchSnapshot('test results');
expect(summary).toMatchSnapshot('test summary');
});
}
expect(exitCode).toBe(0);
});
8 changes: 4 additions & 4 deletions e2e/__tests__/watchModePatterns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ test('can press "p" to filter by file name', () => {

expect(stdout).toMatchSnapshot();
expect(results).toHaveLength(2);
results.forEach(({rest, summary}) => {
for (const {rest, summary} of results) {
expect(rest).toMatchSnapshot('test results');
expect(summary).toMatchSnapshot('test summary');
});
}
expect(exitCode).toBe(0);
});

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

expect(stdout).toMatchSnapshot();
expect(results).toHaveLength(2);
results.forEach(({rest, summary}) => {
for (const {rest, summary} of results) {
expect(rest).toMatchSnapshot('test results');
expect(summary).toMatchSnapshot('test summary');
});
}
expect(exitCode).toBe(0);
});
4 changes: 2 additions & 2 deletions e2e/__tests__/watchModeUpdateSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ test('can press "u" to update snapshots', () => {
const {exitCode, stderr} = runJest(DIR, ['--no-watchman', '--watchAll']);
const results = extractSummaries(stderr);
expect(results).toHaveLength(2);
results.forEach(({rest, summary}) => {
for (const {rest, summary} of results) {
expect(rest).toMatchSnapshot('test results');
expect(summary).toMatchSnapshot('test summary');
});
}
expect(exitCode).toBe(0);
});
2 changes: 1 addition & 1 deletion e2e/babel-plugin-jest-hoist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"react": "17.0.2"
"react": "18.2.0"
},
"jest": {
"automock": true,
Expand Down
Loading

0 comments on commit f827305

Please sign in to comment.