chore!: drop support for node.js version 16 (#15623)

This commit is contained in:
Svyatoslav Zaytsev 2025-05-27 04:23:40 +05:00 committed by GitHub
parent 91ae99c26d
commit 57a0ef1803
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
75 changed files with 136 additions and 165 deletions

View File

@ -58,5 +58,5 @@ workflows:
name: test-node-partial-<< matrix.node-version >>
matrix:
parameters:
node-version: ['16', '18', '20', '22', '23']
node-version: ['18', '20', '22', '23', '24']
- test-jest-jasmine

View File

@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x, 22.x, 23.x]
node-version: [18.x, 20.x, 22.x, 23.x, 24.x]
name: Node v${{ matrix.node-version }}
runs-on: ${{ inputs.os }}

View File

@ -116,7 +116,7 @@
### Chore & Maintenance
- `[*]` Increase version of `micromatch` to `^4.0.7` ([#15082](https://github.com/jestjs/jest/pull/15082))
- `[*]` [**BREAKING**] Drop support for Node.js versions 14, 19 and 21 ([#14460](https://github.com/jestjs/jest/pull/14460), [#15118](https://github.com/jestjs/jest/pull/15118))
- `[*]` [**BREAKING**] Drop support for Node.js versions 14, 16, 19 and 21 ([#14460](https://github.com/jestjs/jest/pull/14460), [#15118](https://github.com/jestjs/jest/pull/15118), [#15623](https://github.com/jestjs/jest/pull/15623))
- `[*]` [**BREAKING**] Drop support for `typescript@4.3`, minimum version is now `5.0` ([#14542](https://github.com/jestjs/jest/pull/14542))
- `[*]` Depend on exact versions of monorepo dependencies instead of `^` range ([#14553](https://github.com/jestjs/jest/pull/14553))
- `[*]` [**BREAKING**] Add ESM wrapper for all of Jest's modules ([#14661](https://github.com/jestjs/jest/pull/14661))

View File

@ -53,7 +53,7 @@ gen_enforced_field(WorkspaceCwd, 'publishConfig.access', null) :-
workspace_field(WorkspaceCwd, 'private', true).
% Enforces the engines.node field for public workspace
gen_enforced_field(WorkspaceCwd, 'engines.node', '^16.10.0 || ^18.12.0 || >=20.0.0') :-
gen_enforced_field(WorkspaceCwd, 'engines.node', '^18.14.0 || ^20.0.0 || >=22.0.0') :-
\+ workspace_field(WorkspaceCwd, 'private', true).
% Enforces the main and types field to start with ./

View File

@ -1,6 +1,11 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`on node >=23.6 invalid JS in jest.config.ts (node with native TS support) 1`] = `
exports[`on node >=24 invalid JS in jest.config.ts (node with native TS support) 1`] = `
"Error: Jest: Failed to parse the TypeScript config file <<REPLACED>>
SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]: Expected ';', got 'string literal (ll break this file yo, 'll break this file yo)'"
`;
exports[`on node ^23.6 invalid JS in jest.config.ts (node with native TS support) 1`] = `
"Error: Jest: Failed to parse the TypeScript config file <<REPLACED>>
SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]: x Expected ';', got 'string literal (ll break this file yo, 'll break this file yo)'
,----

View File

@ -135,7 +135,35 @@ onNodeVersions('<23.6', () => {
});
});
onNodeVersions('>=23.6', () => {
onNodeVersions('^23.6', () => {
test('invalid JS in jest.config.ts (node with native TS support)', () => {
writeFiles(DIR, {
'__tests__/a-giraffe.js': "test('giraffe', () => expect(1).toBe(1));",
'jest.config.ts': "export default i'll break this file yo",
'package.json': '{}',
});
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false'], {
nodeOptions: '--no-warnings',
});
expect(
stderr
// Remove the stack trace from the error message
.slice(0, Math.max(0, stderr.indexOf('at readConfigFileAndSetRootDir')))
.trim()
// Replace the path to the config file with a placeholder
.replace(
/(Error: Jest: Failed to parse the TypeScript config file).*$/m,
'$1 <<REPLACED>>',
),
).toMatchSnapshot();
expect(exitCode).toBe(1);
});
});
onNodeVersions('>=24', () => {
// todo fixme
// eslint-disable-next-line jest/no-identical-title
test('invalid JS in jest.config.ts (node with native TS support)', () => {
writeFiles(DIR, {
'__tests__/a-giraffe.js': "test('giraffe', () => expect(1).toBe(1));",

View File

@ -18,11 +18,11 @@
"@lerna-lite/cli": "^3.0.0",
"@lerna-lite/publish": "^3.0.0",
"@microsoft/api-extractor": "^7.35.0",
"@tsconfig/node16": "^16.1.0",
"@tsconfig/node18": "^18.2.4",
"@types/babel__core": "^7.1.14",
"@types/babel__generator": "^7.0.0",
"@types/babel__template": "^7.0.2",
"@types/node": "^16.10.0",
"@types/node": "^18.14",
"@types/which": "^3.0.0",
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
@ -192,10 +192,10 @@
"logo": "https://opencollective.com/jest/logo.txt"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"resolutions": {
"@types/node": "~16.18.0",
"@types/node": "~18.14",
"@types/react": "^18.2.21",
"ansi-escapes/type-fest": "^2.0.0",
"babel-jest": "workspace:*",
@ -204,7 +204,8 @@
"lru-cache@^10.0.1": "patch:lru-cache@npm:10.4.3#./.yarn/patches/lru-cache-npm-10.4.3-30c10b861a.patch",
"lru-cache@^10.2.0": "patch:lru-cache@npm:10.4.3#./.yarn/patches/lru-cache-npm-10.4.3-30c10b861a.patch",
"lru-cache@^10.2.2": "patch:lru-cache@npm:10.4.3#./.yarn/patches/lru-cache-npm-10.4.3-30c10b861a.patch",
"ts-node@^10.5.0": "patch:ts-node@npm:^10.5.0#./.yarn/patches/ts-node-npm-10.9.1-6c268be7f4.patch"
"ts-node@^10.5.0": "patch:ts-node@npm:^10.5.0#./.yarn/patches/ts-node-npm-10.9.1-6c268be7f4.patch",
"typescript": "~5.5.4"
},
"packageManager": "yarn@3.8.7"
}

View File

@ -37,7 +37,7 @@
"@babel/core": "^7.11.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -7,7 +7,7 @@
"directory": "packages/babel-plugin-jest-hoist"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -20,7 +20,7 @@
"@babel/core": "^7.11.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -31,7 +31,7 @@
"prompts": "^2.0.1"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -16,7 +16,7 @@
"diff"
],
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"main": "./build/index.js",
"types": "./build/index.d.ts",

View File

@ -26,7 +26,7 @@
"jest-matcher-utils": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -35,7 +35,7 @@
"immutable": "^5.0.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -24,7 +24,7 @@
"p-limit": "^3.1.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -52,7 +52,7 @@
"tempy": "^1.0.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -41,7 +41,7 @@
"jest": "./bin/jest.js"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"repository": {
"type": "git",

View File

@ -71,7 +71,7 @@
"typescript": "^5.0.4"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -16,9 +16,6 @@ function __setCpus(newCpus) {
os.__setCpus = __setCpus;
os.cpus = jest.fn(() => cpus);
if (typeof os.availableParallelism === 'function') {
os.availableParallelism = jest.fn(() => cpus?.length ?? 0);
}
os.availableParallelism = jest.fn(() => cpus?.length ?? 0);
module.exports = os;

View File

@ -1142,9 +1142,8 @@ describe('preset', () => {
{virtual: true},
);
const errorMessage = semver.satisfies(process.versions.node, '<16.9.1')
? /TypeError: Cannot read property 'call' of undefined[\S\s]* at /
: "TypeError: Cannot read properties of undefined (reading 'call')";
const errorMessage =
"TypeError: Cannot read properties of undefined (reading 'call')";
await expect(
normalize(

View File

@ -5,19 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import {
// @ts-expect-error - added in Node 19.4.0
availableParallelism,
cpus,
} from 'os';
import {availableParallelism} from 'os';
import type {Config} from '@jest/types';
function getNumCpus(): number {
return typeof availableParallelism === 'function'
? availableParallelism()
: (cpus()?.length ?? 1);
}
export default function getMaxWorkers(
argv: Partial<
Pick<Config.Argv, 'maxWorkers' | 'runInBand' | 'watch' | 'watchAll'>
@ -32,7 +22,7 @@ export default function getMaxWorkers(
return parseWorkers(defaultOptions.maxWorkers);
} else {
// In watch mode, Jest should be unobtrusive and not use all available CPUs.
const numCpus = getNumCpus();
const numCpus = availableParallelism();
const isWatchModeEnabled = argv.watch || argv.watchAll;
return Math.max(
isWatchModeEnabled ? Math.floor(numCpus / 2) : numCpus - 1,
@ -50,7 +40,7 @@ const parseWorkers = (maxWorkers: string | number): number => {
parsed > 0 &&
parsed <= 100
) {
const numCpus = getNumCpus();
const numCpus = availableParallelism();
const workers = Math.floor((parsed / 100) * numCpus);
return Math.max(workers, 1);
}

View File

@ -36,14 +36,11 @@ export default async function readConfigFileAndSetRootDir(
configPath.endsWith(JEST_CONFIG_EXT_TS) ||
configPath.endsWith(JEST_CONFIG_EXT_CTS);
const isJSON = configPath.endsWith(JEST_CONFIG_EXT_JSON);
// type assertion can be removed once @types/node is updated
// https://nodejs.org/api/process.html#processfeaturestypescript
const supportsTS = (process.features as {typescript?: boolean | string})
.typescript;
let configObject;
try {
if (isTS && !supportsTS) {
// @ts-expect-error: type assertion can be removed once @types/node is updated to 23 https://nodejs.org/api/process.html#processfeaturestypescript
if (isTS && !process.features.typescript) {
configObject = await loadTSConfigFile(configPath);
} else if (isJSON) {
const fileContent = fs.readFileSync(configPath, 'utf8');

View File

@ -30,7 +30,7 @@
"@jest/test-utils": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -59,7 +59,7 @@
}
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"repository": {
"type": "git",

View File

@ -14,7 +14,7 @@
"jest-util": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -29,7 +29,7 @@
"strip-ansi": "^6.0.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -25,7 +25,7 @@
"@types/node": "*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -34,7 +34,7 @@
"pretty-format": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -40,7 +40,7 @@
}
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -37,7 +37,7 @@
}
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -30,7 +30,7 @@
"@jest/test-utils": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -23,7 +23,7 @@
"jest-mock": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -23,7 +23,7 @@
"jest-snapshot": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -31,7 +31,7 @@
"@types/sinonjs__fake-timers": "^8.1.2"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -8,7 +8,7 @@
"directory": "packages/jest-get-type"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -7,7 +7,7 @@
"directory": "packages/jest-globals"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -40,7 +40,7 @@
"fsevents": "^2.3.2"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -41,7 +41,7 @@
"@types/co": "^4.6.2"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -26,7 +26,7 @@
"@types/node": "*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -8,7 +8,7 @@
"directory": "packages/jest-matcher-utils"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -7,7 +7,7 @@
"directory": "packages/jest-message-util"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -24,7 +24,7 @@
"jest-util": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -23,7 +23,7 @@
"jest-regex-util": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -20,7 +20,7 @@
"@jest/test-result": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -10,7 +10,7 @@
"@types/node": "*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -42,7 +42,7 @@
"jest-runtime": "./bin/jest-runtime-cli.js"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -5,11 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {
// @ts-expect-error - added in Node 19.4.0
availableParallelism,
cpus,
} from 'os';
import {availableParallelism} from 'os';
import * as path from 'path';
import * as util from 'util';
import chalk = require('chalk');
@ -75,10 +71,7 @@ export async function run(
};
try {
const numCpus: number =
typeof availableParallelism === 'function'
? availableParallelism()
: cpus().length;
const numCpus = availableParallelism();
const hasteMap = await Runtime.createContext(projectConfig, {
maxWorkers: Math.max(numCpus - 1, 1),

View File

@ -62,7 +62,7 @@
}
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"repository": {
"type": "git",

View File

@ -30,7 +30,7 @@
"jest-runtime": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -35,7 +35,7 @@
"@types/resolve": "^1.20.2"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -48,7 +48,7 @@
"jest-jasmine2": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -48,7 +48,7 @@
"jest-environment-node": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -530,6 +530,7 @@ export default class Runtime {
// @ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/node@20.11.0
meta.dirname = path.dirname(modulePath);
// @ts-expect-error: todo fixme
meta.resolve = (specifier, parent = metaUrl) => {
const parentPath = fileURLToPath(parent);

View File

@ -22,7 +22,7 @@
"@sinclair/typebox": "^0.34.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -29,7 +29,7 @@
"@types/natural-compare": "^1.4.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -55,7 +55,7 @@
"prettier-v2": "npm:prettier@^2.1.5"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -27,7 +27,7 @@
"@types/graceful-fs": "^4.1.3"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -29,7 +29,7 @@
"jest-resolve": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -29,7 +29,7 @@
"@types/graceful-fs": "^4.1.3"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -45,7 +45,7 @@
"dedent": "^1.0.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -7,7 +7,7 @@
"directory": "packages/jest-types"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"license": "MIT",
"main": "./build/index.js",

View File

@ -31,7 +31,7 @@
"@types/picomatch": "^4.0.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -30,7 +30,7 @@
"@types/yargs": "^17.0.8"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -32,7 +32,7 @@
"url": "https://github.com/jestjs/jest/issues"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"homepage": "https://jestjs.io/",
"license": "MIT",

View File

@ -35,7 +35,7 @@
"worker-farm": "^1.6.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -5,11 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {
// @ts-expect-error - added in Node 19.4.0
availableParallelism,
cpus,
} from 'os';
import {availableParallelism} from 'os';
import {isAbsolute} from 'path';
import {fileURLToPath} from 'url';
import Farm from './Farm';
@ -59,12 +55,6 @@ function getExposedMethods(
return exposedMethods;
}
function getNumberOfCpus(): number {
return typeof availableParallelism === 'function'
? availableParallelism()
: cpus().length;
}
/**
* The Jest farm (publicly called "Worker") is a class that allows you to queue
* methods across multiple child processes, in order to parallelize work. This
@ -116,7 +106,7 @@ export class Worker {
idleMemoryLimit: this._options.idleMemoryLimit,
maxRetries: this._options.maxRetries ?? 3,
numWorkers:
this._options.numWorkers ?? Math.max(getNumberOfCpus() - 1, 1),
this._options.numWorkers ?? Math.max(availableParallelism() - 1, 1),
resourceLimits: this._options.resourceLimits ?? {},
setupArgs: this._options.setupArgs ?? [],
};

View File

@ -30,7 +30,7 @@
},
"bin": "./bin/jest.js",
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"repository": {
"type": "git",

View File

@ -36,7 +36,7 @@
"react-test-renderer": "18.2.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -18,6 +18,6 @@
"jest-mock": "workspace:*"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
}
}

View File

@ -27,6 +27,6 @@
"@types/semver": "^7.1.0"
},
"engines": {
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
"node": "^18.14.0 || ^20.0.0 || >=22.0.0"
}
}

View File

@ -176,12 +176,7 @@ try {
console.log(chalk.inverse(' Validating TypeScript definition files '));
// we want to limit the number of processes we spawn
const cpus = Math.max(
1,
(typeof os.availableParallelism === 'function'
? os.availableParallelism()
: os.cpus().length) - 1,
);
const cpus = Math.max(1, os.availableParallelism() - 1);
const typesReferenceDirective = '/// <reference types';
const typesNodeReferenceDirective = `${typesReferenceDirective}="node" />`;

View File

@ -18,12 +18,7 @@ import typescriptEslint from 'typescript-eslint';
import {getPackagesWithTsConfig} from './buildUtils.mjs';
// we want to limit the number of processes we spawn
const cpus = Math.max(
1,
(typeof os.availableParallelism === 'function'
? os.availableParallelism()
: os.cpus().length) - 1,
);
const cpus = Math.max(1, os.availableParallelism() - 1);
const mutex = pLimit(cpus);

View File

@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node16/tsconfig.json",
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"module": "preserve",
"moduleResolution": "bundler",

View File

@ -1,5 +1,5 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"module": "preserve",
"moduleResolution": "bundler",

View File

@ -3892,11 +3892,11 @@ __metadata:
"@lerna-lite/cli": ^3.0.0
"@lerna-lite/publish": ^3.0.0
"@microsoft/api-extractor": ^7.35.0
"@tsconfig/node16": ^16.1.0
"@tsconfig/node18": ^18.2.4
"@types/babel__core": ^7.1.14
"@types/babel__generator": ^7.0.0
"@types/babel__template": ^7.0.2
"@types/node": ^16.10.0
"@types/node": ^18.14
"@types/which": ^3.0.0
ansi-regex: ^5.0.1
ansi-styles: ^5.0.0
@ -5720,10 +5720,10 @@ __metadata:
languageName: node
linkType: hard
"@tsconfig/node16@npm:^16.1.0":
version: 16.1.3
resolution: "@tsconfig/node16@npm:16.1.3"
checksum: 097f33cb7fe9577cc3c4b7a8d26c7e8b6c45c868d3bda1e2cd120111693b98f88a5138e643e7a6f79d53d94717c3624dc33398804647bf6e0e8782604bbfad53
"@tsconfig/node18@npm:^18.2.4":
version: 18.2.4
resolution: "@tsconfig/node18@npm:18.2.4"
checksum: 80623cb9c129c78d51fe6c4a256ba986f12f02ff02dc2a1e5b33dd13a7983f767b6792cfcd51b3dd1c8256ea105f1fea31f64a2070564e37787ab3d9a1a1e7e3
languageName: node
linkType: hard
@ -6188,10 +6188,10 @@ __metadata:
languageName: node
linkType: hard
"@types/node@npm:~16.18.0":
version: 16.18.126
resolution: "@types/node@npm:16.18.126"
checksum: 86112e7499f8a4d1bb60696cab0bf464adf3c141fca4bc5451e8f3aba5736529b76d4b4396edb21e5d7c19592852f7d6cb81ee70074fd13bde2db2d0db720467
"@types/node@npm:~18.14":
version: 18.14.6
resolution: "@types/node@npm:18.14.6"
checksum: 2f88f482cabadc6dbddd627a1674239e68c3c9beab56eb4ae2309fb96fd17fc3a509d99b0309bafe13b58529574f49ecf3a583f2ebe2896dd32fe4be436dc96e
languageName: node
linkType: hard
@ -21538,43 +21538,23 @@ __metadata:
languageName: node
linkType: hard
"typescript@npm:5.8.2":
version: 5.8.2
resolution: "typescript@npm:5.8.2"
"typescript@npm:~5.5.4":
version: 5.5.4
resolution: "typescript@npm:5.5.4"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 7f9e3d7ac15da6df713e439e785e51facd65d6450d5f51fab3e8d2f2e3f4eb317080d895480b8e305450cdbcb37e17383e8bf521e7395f8b556e2f2a4730ed86
checksum: b309040f3a1cd91c68a5a58af6b9fdd4e849b8c42d837b2c2e73f9a4f96a98c4f1ed398a9aab576ee0a4748f5690cf594e6b99dbe61de7839da748c41e6d6ca8
languageName: node
linkType: hard
"typescript@npm:^5.0.4":
version: 5.8.3
resolution: "typescript@npm:5.8.3"
"typescript@patch:typescript@npm%3A~5.5.4#~builtin<compat/typescript>":
version: 5.5.4
resolution: "typescript@patch:typescript@npm%3A5.5.4#~builtin<compat/typescript>::version=5.5.4&hash=379a07"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: cb1d081c889a288b962d3c8ae18d337ad6ee88a8e81ae0103fa1fecbe923737f3ba1dbdb3e6d8b776c72bc73bfa6d8d850c0306eed1a51377d2fccdfd75d92c4
languageName: node
linkType: hard
"typescript@patch:typescript@5.8.2#~builtin<compat/typescript>":
version: 5.8.2
resolution: "typescript@patch:typescript@npm%3A5.8.2#~builtin<compat/typescript>::version=5.8.2&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 557109f14248260656c551f1a8bf8de188d5397928a8ae6e6f00e268f25975b6e572522085ae8e06683de019b1885781f50090f07c4f0a9a34d60c459305f80d
languageName: node
linkType: hard
"typescript@patch:typescript@^5.0.4#~builtin<compat/typescript>":
version: 5.8.3
resolution: "typescript@patch:typescript@npm%3A5.8.3#~builtin<compat/typescript>::version=5.8.3&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: f1743b6850976b3debf7cbd53d2bc0b67e75d47eb6410db564c8bb475e92a8a48f8a3fcd14d89cf93426835281c31a8f8a94dad90be4dc899279a898532ba97f
checksum: e14c87e8bd51f9ac741051a2c3bde75b2a3ab17dee2c50239f7e1a0868673f3b7d4d87684df41a59a8f57c6ddc5d06d65d120764d992441af5de07b98cf9c67b
languageName: node
linkType: hard