From 0b219368af39269fd1cd909cdbcbb631350d2281 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 5 Jan 2022 23:09:35 +0100 Subject: [PATCH 1/6] chore: drop node 10 and node 15 --- .circleci/config.yml | 2 +- .github/workflows/nodejs.yml | 2 +- CHANGELOG.md | 2 + .../consoleLogOutputWhenRunInBand.test.ts | 16 +---- e2e/__tests__/detectOpenHandles.ts | 35 +++++----- e2e/__tests__/errorOnDeprecated.test.ts | 18 +----- e2e/__tests__/failures.test.ts | 14 ---- .../requireMainAfterCreateRequire.test.ts | 20 +++--- e2e/__tests__/unexpectedToken.test.ts | 11 +--- package.json | 6 +- packages/babel-jest/package.json | 2 +- packages/babel-plugin-jest-hoist/package.json | 2 +- packages/babel-preset-jest/package.json | 2 +- packages/diff-sequences/package.json | 2 +- packages/expect/package.json | 2 +- packages/jest-changed-files/package.json | 2 +- packages/jest-circus/package.json | 2 +- packages/jest-cli/package.json | 2 +- packages/jest-config/package.json | 2 +- packages/jest-console/package.json | 2 +- packages/jest-core/package.json | 2 +- packages/jest-core/src/collectHandles.ts | 5 +- .../package.json | 2 +- packages/jest-diff/package.json | 2 +- packages/jest-docblock/package.json | 2 +- packages/jest-each/package.json | 2 +- packages/jest-environment-jsdom/package.json | 2 +- packages/jest-environment-node/package.json | 2 +- packages/jest-environment/package.json | 2 +- packages/jest-fake-timers/package.json | 2 +- packages/jest-get-type/package.json | 2 +- packages/jest-globals/package.json | 2 +- packages/jest-haste-map/package.json | 2 +- packages/jest-jasmine2/package.json | 2 +- packages/jest-leak-detector/package.json | 2 +- packages/jest-matcher-utils/package.json | 2 +- packages/jest-message-util/package.json | 2 +- packages/jest-mock/package.json | 2 +- packages/jest-phabricator/package.json | 2 +- packages/jest-regex-util/package.json | 2 +- packages/jest-repl/package.json | 2 +- packages/jest-reporters/package.json | 2 +- .../jest-resolve-dependencies/package.json | 2 +- packages/jest-resolve/package.json | 2 +- packages/jest-runner/package.json | 2 +- packages/jest-runtime/package.json | 2 +- .../__tests__/runtime_require_module.test.js | 64 +++++++++---------- packages/jest-serializer/package.json | 2 +- packages/jest-snapshot/package.json | 2 +- packages/jest-source-map/package.json | 2 +- packages/jest-test-result/package.json | 2 +- packages/jest-test-sequencer/package.json | 2 +- packages/jest-transform/package.json | 2 +- packages/jest-types/package.json | 2 +- packages/jest-util/package.json | 2 +- packages/jest-validate/package.json | 2 +- packages/jest-watcher/package.json | 2 +- packages/jest-worker/package.json | 2 +- .../src/workers/NodeThreadsWorker.ts | 1 - packages/jest/package.json | 2 +- packages/pretty-format/package.json | 2 +- packages/test-utils/package.json | 2 +- scripts/buildUtils.js | 3 +- tsconfig.json | 4 +- yarn.lock | 26 ++++---- 65 files changed, 133 insertions(+), 194 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index addb05e4fec8..b2531d1f6416 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,5 +68,5 @@ workflows: partial: true matrix: parameters: - node-version: ['10', '12', '15', '16', '17'] + node-version: ['12', '16', '17'] - test-jest-jasmine diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 631345fcf305..3077894fcd19 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -69,7 +69,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [10.x, 12.x, 14.x, 15.x, 16.x, 17.x] + node-version: [12.x, 14.x, 16.x, 17.x] os: [ubuntu-latest, macOS-latest, windows-latest] runs-on: ${{ matrix.os }} needs: prepare-yarn-cache diff --git a/CHANGELOG.md b/CHANGELOG.md index ce76556d651a..358f7b4f11b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Chore & Maintenance +- `[*]` Drop support for Node v10 and v15 and target first LTS `16.13.0` ([#12220](https://github.com/facebook/jest/pull/12220)) + ### Performance ## 27.5.1 diff --git a/e2e/__tests__/consoleLogOutputWhenRunInBand.test.ts b/e2e/__tests__/consoleLogOutputWhenRunInBand.test.ts index 227e94f83e5a..914a853b5eb7 100644 --- a/e2e/__tests__/consoleLogOutputWhenRunInBand.test.ts +++ b/e2e/__tests__/consoleLogOutputWhenRunInBand.test.ts @@ -14,8 +14,6 @@ const DIR = path.resolve(__dirname, '../console-log-output-when-run-in-band'); beforeEach(() => cleanup(DIR)); afterAll(() => cleanup(DIR)); -const nodeMajorVersion = Number(process.versions.node.split('.')[0]); - test('prints console.logs when run with forceExit', () => { writeFiles(DIR, { '__tests__/a-banana.js': ` @@ -24,26 +22,14 @@ test('prints console.logs when run with forceExit', () => { 'package.json': '{}', }); - const {stderr, exitCode, ...res} = runJest(DIR, [ + const {stderr, stdout, exitCode} = runJest(DIR, [ '-i', '--ci=false', '--forceExit', ]); - let {stdout} = res; const {rest, summary} = extractSummary(stderr); - if (nodeMajorVersion < 12) { - expect(stdout).toContain( - 'at Object..test (__tests__/a-banana.js:1:1)', - ); - - stdout = stdout.replace( - 'at Object..test (__tests__/a-banana.js:1:1)', - 'at Object. (__tests__/a-banana.js:1:1)', - ); - } - expect(exitCode).toBe(0); expect(rest).toMatchSnapshot(); expect(summary).toMatchSnapshot(); diff --git a/e2e/__tests__/detectOpenHandles.ts b/e2e/__tests__/detectOpenHandles.ts index 971ef1d69d09..860f5368c6df 100644 --- a/e2e/__tests__/detectOpenHandles.ts +++ b/e2e/__tests__/detectOpenHandles.ts @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import {onNodeVersions} from '@jest/test-utils'; import runJest, {runContinuous} from '../runJest'; try { @@ -81,16 +80,14 @@ it('does not report crypto random data', () => { expect(textAfterTest).toBe(''); }); -onNodeVersions('>=12', () => { - it('does not report ELD histograms', () => { - const {stderr} = runJest('detect-open-handles', [ - 'histogram', - '--detectOpenHandles', - ]); - const textAfterTest = getTextAfterTest(stderr); +it('does not report ELD histograms', () => { + const {stderr} = runJest('detect-open-handles', [ + 'histogram', + '--detectOpenHandles', + ]); + const textAfterTest = getTextAfterTest(stderr); - expect(textAfterTest).toBe(''); - }); + expect(textAfterTest).toBe(''); }); describe('notify', () => { @@ -109,17 +106,15 @@ describe('notify', () => { }); }); -onNodeVersions('>=12', () => { - it('does not report timeouts using unref', () => { - // The test here is basically that it exits cleanly without reporting anything (does not need `until`) - const {stderr} = runJest('detect-open-handles', [ - 'unref', - '--detectOpenHandles', - ]); - const textAfterTest = getTextAfterTest(stderr); +it('does not report timeouts using unref', () => { + // The test here is basically that it exits cleanly without reporting anything (does not need `until`) + const {stderr} = runJest('detect-open-handles', [ + 'unref', + '--detectOpenHandles', + ]); + const textAfterTest = getTextAfterTest(stderr); - expect(textAfterTest).toBe(''); - }); + expect(textAfterTest).toBe(''); }); it('prints out info about open handlers from inside tests', async () => { diff --git a/e2e/__tests__/errorOnDeprecated.test.ts b/e2e/__tests__/errorOnDeprecated.test.ts index 82069e754f62..5527f81c5ef9 100644 --- a/e2e/__tests__/errorOnDeprecated.test.ts +++ b/e2e/__tests__/errorOnDeprecated.test.ts @@ -31,8 +31,6 @@ const SHOULD_NOT_PASS_IN_JEST = new Set([ 'spyOnProperty.test.js', ]); -const nodeMajorVersion = Number(process.versions.node.split('.')[0]); - testFiles.forEach(testFile => { test(`${testFile} errors in errorOnDeprecated mode`, () => { const result = runJest('error-on-deprecated', [ @@ -40,21 +38,7 @@ testFiles.forEach(testFile => { '--errorOnDeprecated', ]); expect(result.exitCode).toBe(1); - let {rest} = extractSummary(result.stderr); - - if ( - nodeMajorVersion < 12 && - testFile === 'defaultTimeoutInterval.test.js' - ) { - const lineEntry = '(__tests__/defaultTimeoutInterval.test.js:10:3)'; - - expect(rest).toContain(`at Object..test ${lineEntry}`); - - rest = rest.replace( - `at Object..test ${lineEntry}`, - `at Object. ${lineEntry}`, - ); - } + const {rest} = extractSummary(result.stderr); expect(rest).toMatchSnapshot(); }); diff --git a/e2e/__tests__/failures.test.ts b/e2e/__tests__/failures.test.ts index 98153dcd1011..6dfb810be8d7 100644 --- a/e2e/__tests__/failures.test.ts +++ b/e2e/__tests__/failures.test.ts @@ -20,8 +20,6 @@ function cleanStderr(stderr: string) { .replace(new RegExp('Failed: Object {', 'g'), 'thrown: Object {'); } -const nodeMajorVersion = Number(process.versions.node.split('.')[0]); - beforeAll(() => { runYarnInstall(dir); }); @@ -37,18 +35,6 @@ test('not throwing Error objects', () => { stderr = runJest(dir, ['assertionCount.test.js']).stderr; expect(cleanStderr(stderr)).toMatchSnapshot(); stderr = runJest(dir, ['duringTests.test.js']).stderr; - - if (nodeMajorVersion < 12) { - const lineEntry = '(__tests__/duringTests.test.js:43:8)'; - - expect(stderr).toContain(`at Object..done ${lineEntry}`); - - stderr = stderr.replace( - `at Object..done ${lineEntry}`, - `at Object. ${lineEntry}`, - ); - } - expect(cleanStderr(stderr)).toMatchSnapshot(); stderr = runJest(dir, ['throwObjectWithStackProp.test.js']).stderr; expect(cleanStderr(stderr)).toMatchSnapshot(); diff --git a/e2e/__tests__/requireMainAfterCreateRequire.test.ts b/e2e/__tests__/requireMainAfterCreateRequire.test.ts index 6bd837366974..95ef949fd5c2 100644 --- a/e2e/__tests__/requireMainAfterCreateRequire.test.ts +++ b/e2e/__tests__/requireMainAfterCreateRequire.test.ts @@ -4,19 +4,17 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ + import * as path from 'path'; -import {onNodeVersions} from '@jest/test-utils'; import runJest from '../runJest'; -onNodeVersions('>=12.2.0', () => { - test('`require.main` not undefined after createRequire', () => { - const {stdout} = runJest('require-main-after-create-require'); +test('`require.main` not undefined after createRequire', () => { + const {stdout} = runJest('require-main-after-create-require'); - expect(stdout).toBe( - path.join( - __dirname, - '../require-main-after-create-require/__tests__/parent.test.js', - ), - ); - }); + expect(stdout).toBe( + path.join( + __dirname, + '../require-main-after-create-require/__tests__/parent.test.js', + ), + ); }); diff --git a/e2e/__tests__/unexpectedToken.test.ts b/e2e/__tests__/unexpectedToken.test.ts index 0f5aaf63f1de..28f3fc279747 100644 --- a/e2e/__tests__/unexpectedToken.test.ts +++ b/e2e/__tests__/unexpectedToken.test.ts @@ -11,7 +11,6 @@ import {cleanup, writeFiles} from '../Utils'; import runJest from '../runJest'; const DIR = path.resolve(tmpdir(), 'unexpected-token'); -const nodeMajorVersion = Number(process.versions.node.split('.')[0]); beforeEach(() => cleanup(DIR)); afterEach(() => cleanup(DIR)); @@ -53,13 +52,9 @@ test('triggers unexpected token error message for untranspiled node_modules', () expect(stdout).toBe(''); expect(stderr).toMatch(/Jest encountered an unexpected token/); expect(stderr).toMatch(/import {module}/); - if (nodeMajorVersion < 12) { - expect(stderr).toMatch(/Unexpected token/); - } else { - expect(stderr).toMatch( - /SyntaxError: Cannot use import statement outside a module/, - ); - } + expect(stderr).toMatch( + /SyntaxError: Cannot use import statement outside a module/, + ); }); test('does not trigger unexpected token error message for regular syntax errors', () => { diff --git a/package.json b/package.json index b822c61cf530..8fe972396eff 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,14 @@ "@crowdin/cli": "^3.5.2", "@jest/globals": "workspace:*", "@jest/test-utils": "workspace:*", - "@tsconfig/node10": "^1.0.8", + "@tsconfig/node12": "^1.0.9", "@tsd/typescript": "~4.1.5", "@types/babel__core": "^7.0.0", "@types/babel__generator": "^7.0.0", "@types/babel__template": "^7.0.0", "@types/dedent": "0.7.0", "@types/jest": "^26.0.15", - "@types/node": "~10.14.0", + "@types/node": "~12.12.0", "@types/which": "^2.0.0", "@typescript-eslint/eslint-plugin": "^4.1.0", "@typescript-eslint/parser": "^4.1.0", @@ -145,7 +145,7 @@ "logo": "https://opencollective.com/jest/logo.txt" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "resolutions": { "@jest/create-cache-key-function": "workspace:*", diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index 0408261931dd..dc8d22138b44 100644 --- a/packages/babel-jest/package.json +++ b/packages/babel-jest/package.json @@ -36,7 +36,7 @@ "@babel/core": "^7.8.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/babel-plugin-jest-hoist/package.json b/packages/babel-plugin-jest-hoist/package.json index 5c018acb991e..8e1ce14cd1eb 100644 --- a/packages/babel-plugin-jest-hoist/package.json +++ b/packages/babel-plugin-jest-hoist/package.json @@ -7,7 +7,7 @@ "directory": "packages/babel-plugin-jest-hoist" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/babel-preset-jest/package.json b/packages/babel-preset-jest/package.json index 13b8a6a7d7cc..be29d9bf0474 100644 --- a/packages/babel-preset-jest/package.json +++ b/packages/babel-preset-jest/package.json @@ -20,7 +20,7 @@ "@babel/core": "^7.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/diff-sequences/package.json b/packages/diff-sequences/package.json index 2e33b0685932..3a728705cc96 100644 --- a/packages/diff-sequences/package.json +++ b/packages/diff-sequences/package.json @@ -16,7 +16,7 @@ "diff" ], "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "main": "./build/index.js", "types": "./build/index.d.ts", diff --git a/packages/expect/package.json b/packages/expect/package.json index b1c7cca021ab..7687b97bc953 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -33,7 +33,7 @@ "tsd-lite": "^0.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-changed-files/package.json b/packages/jest-changed-files/package.json index 2f6369874d0e..c63d3c9d6f48 100644 --- a/packages/jest-changed-files/package.json +++ b/packages/jest-changed-files/package.json @@ -22,7 +22,7 @@ "throat": "^6.0.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index 4a8eeb821fb8..78fb17cba128 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -49,7 +49,7 @@ "graceful-fs": "^4.2.9" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 724fee9ccc79..5722da65e706 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -44,7 +44,7 @@ "jest": "./bin/jest.js" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "repository": { "type": "git", diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 059e98235ab2..85df2d4f64e6 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -59,7 +59,7 @@ "typescript": "^4.0.3" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 78bc31296d45..8e6dde21ffd7 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -29,7 +29,7 @@ "@types/node": "*" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 15120d1ad44a..36d372064557 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -58,7 +58,7 @@ } }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "repository": { "type": "git", diff --git a/packages/jest-core/src/collectHandles.ts b/packages/jest-core/src/collectHandles.ts index 72fea6ee6b94..88fe14a4b1de 100644 --- a/packages/jest-core/src/collectHandles.ts +++ b/packages/jest-core/src/collectHandles.ts @@ -40,7 +40,7 @@ function stackIsFromUser(stack: string) { const alwaysActive = () => true; -// @ts-expect-error: doesn't exist in v10 typings +// @ts-expect-error: doesn't exist in v12 typings const hasWeakRef = typeof WeakRef === 'function'; const asyncSleep = promisify(setTimeout); @@ -97,13 +97,12 @@ export default function collectHandles(): HandleCollectionResult { // Timer that supports hasRef (Node v11+) if ('hasRef' in resource) { if (hasWeakRef) { - // @ts-expect-error: doesn't exist in v10 typings + // @ts-expect-error: doesn't exist in v12 typings const ref = new WeakRef(resource); isActive = () => { return ref.deref()?.hasRef() ?? false; }; } else { - // @ts-expect-error: doesn't exist in v10 typings isActive = resource.hasRef.bind(resource); } } else { diff --git a/packages/jest-create-cache-key-function/package.json b/packages/jest-create-cache-key-function/package.json index d5d3388241de..5715193085d0 100644 --- a/packages/jest-create-cache-key-function/package.json +++ b/packages/jest-create-cache-key-function/package.json @@ -14,7 +14,7 @@ "jest-util": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-diff/package.json b/packages/jest-diff/package.json index 85de791ff429..677060b607fc 100644 --- a/packages/jest-diff/package.json +++ b/packages/jest-diff/package.json @@ -27,7 +27,7 @@ "strip-ansi": "^6.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-docblock/package.json b/packages/jest-docblock/package.json index 37bb1495ef0e..f2d1f27d8c3f 100644 --- a/packages/jest-docblock/package.json +++ b/packages/jest-docblock/package.json @@ -23,7 +23,7 @@ "@types/node": "*" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-each/package.json b/packages/jest-each/package.json index 07ba03c4e6a8..43759f094715 100644 --- a/packages/jest-each/package.json +++ b/packages/jest-each/package.json @@ -32,7 +32,7 @@ "pretty-format": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index a7b40f13a23d..ffdcd93a98fa 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -30,7 +30,7 @@ "@types/jsdom": "^16.2.4" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index d627bf0ad612..89f7aa653000 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -28,7 +28,7 @@ "@jest/test-utils": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index f7b13f0e0ae8..a453c1a4fd82 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -23,7 +23,7 @@ "jest-mock": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index f88e1b367d19..7abcc97b1849 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -28,7 +28,7 @@ "@types/sinonjs__fake-timers": "^8.1.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-get-type/package.json b/packages/jest-get-type/package.json index 70818fc54f8d..506b399450b0 100644 --- a/packages/jest-get-type/package.json +++ b/packages/jest-get-type/package.json @@ -8,7 +8,7 @@ "directory": "packages/jest-get-type" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-globals/package.json b/packages/jest-globals/package.json index 8fe74706294e..deb0d63a4598 100644 --- a/packages/jest-globals/package.json +++ b/packages/jest-globals/package.json @@ -7,7 +7,7 @@ "directory": "packages/jest-globals" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index 0029e5f6ff9e..58009665e2c1 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -40,7 +40,7 @@ "fsevents": "^2.3.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index 76ed838135db..76980c211986 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -39,7 +39,7 @@ "@types/co": "^4.6.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-leak-detector/package.json b/packages/jest-leak-detector/package.json index 6cba8460db73..f054114eb0f9 100644 --- a/packages/jest-leak-detector/package.json +++ b/packages/jest-leak-detector/package.json @@ -25,7 +25,7 @@ "weak-napi": "^2.0.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-matcher-utils/package.json b/packages/jest-matcher-utils/package.json index 33c684949e50..60573bd0baa5 100644 --- a/packages/jest-matcher-utils/package.json +++ b/packages/jest-matcher-utils/package.json @@ -8,7 +8,7 @@ "directory": "packages/jest-matcher-utils" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index 21afee9cf31b..2da2b84a2383 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -7,7 +7,7 @@ "directory": "packages/jest-message-util" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 3abfe7a9f752..81194f3a7b6b 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -7,7 +7,7 @@ "directory": "packages/jest-mock" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "dependencies": { "@jest/types": "^27.5.1", diff --git a/packages/jest-phabricator/package.json b/packages/jest-phabricator/package.json index 37a16a63c1ce..e70a9b1a6596 100644 --- a/packages/jest-phabricator/package.json +++ b/packages/jest-phabricator/package.json @@ -18,7 +18,7 @@ "@jest/test-result": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-regex-util/package.json b/packages/jest-regex-util/package.json index 6a589a128593..55038f248cca 100644 --- a/packages/jest-regex-util/package.json +++ b/packages/jest-regex-util/package.json @@ -10,7 +10,7 @@ "@types/node": "*" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index f45587c5e4c8..d0f0e9100b76 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -40,7 +40,7 @@ "jest-runtime": "./bin/jest-runtime-cli.js" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index 8aced6b8fd6e..5d1559af33a6 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -61,7 +61,7 @@ } }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "repository": { "type": "git", diff --git a/packages/jest-resolve-dependencies/package.json b/packages/jest-resolve-dependencies/package.json index f6c2867e3bd2..b1d6a6186c54 100644 --- a/packages/jest-resolve-dependencies/package.json +++ b/packages/jest-resolve-dependencies/package.json @@ -28,7 +28,7 @@ "jest-runtime": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index c2c98de45cac..f692c5d23d71 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -33,7 +33,7 @@ "@types/resolve": "^1.20.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 5ac1fe2b88f4..f8307bbdf5e0 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -46,7 +46,7 @@ "jest-jasmine2": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index 539d1d9b0eb1..9d049b7cc770 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -48,7 +48,7 @@ "jest-environment-node": "^27.5.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index ccef99fb7cd7..de22e6607943 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -372,47 +372,45 @@ describe('Runtime requireModule', () => { ).toThrowError(); }); - onNodeVersions('>=12.12.0', () => { - it('overrides module.createRequire', async () => { - const runtime = await createRuntime(__filename); - const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); + it('overrides module.createRequire', async () => { + const runtime = await createRuntime(__filename); + const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); - expect(exports.createRequire).not.toBe(createRequire); + expect(exports.createRequire).not.toBe(createRequire); - // createRequire with string - { - const customRequire = exports.createRequire(runtime.__mockRootPath); - expect(customRequire('./create_require_module').foo).toBe('foo'); - } + // createRequire with string + { + const customRequire = exports.createRequire(runtime.__mockRootPath); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } - // createRequire with URL object - { - const customRequire = exports.createRequire( - pathToFileURL(runtime.__mockRootPath), - ); - expect(customRequire('./create_require_module').foo).toBe('foo'); - } + // createRequire with URL object + { + const customRequire = exports.createRequire( + pathToFileURL(runtime.__mockRootPath), + ); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } - // createRequire with file URL string - { - const customRequire = exports.createRequire( - pathToFileURL(runtime.__mockRootPath).toString(), - ); - expect(customRequire('./create_require_module').foo).toBe('foo'); - } + // createRequire with file URL string + { + const customRequire = exports.createRequire( + pathToFileURL(runtime.__mockRootPath).toString(), + ); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } - // createRequire with absolute module path - { - const customRequire = exports.createRequire(runtime.__mockRootPath); - expect(customRequire('./create_require_module').foo).toBe('foo'); - } + // createRequire with absolute module path + { + const customRequire = exports.createRequire(runtime.__mockRootPath); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } - expect(exports.syncBuiltinESMExports).not.toThrow(); - expect(exports.builtinModules).toEqual(builtinModules); - }); + expect(exports.syncBuiltinESMExports).not.toThrow(); + expect(exports.builtinModules).toEqual(builtinModules); }); - onNodeVersions('>=12.12.0 <16.0.0', () => { + onNodeVersions('<16.0.0', () => { it('overrides module.createRequireFromPath', async () => { const runtime = await createRuntime(__filename); const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index b4eacc0e6aac..aa9589da0620 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -14,7 +14,7 @@ "graceful-fs": "^4.2.9" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index 32887e6bb831..7503ad7060da 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -52,7 +52,7 @@ "prettier": "^2.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-source-map/package.json b/packages/jest-source-map/package.json index 7925f2cb8e48..572d15e1e85a 100644 --- a/packages/jest-source-map/package.json +++ b/packages/jest-source-map/package.json @@ -25,7 +25,7 @@ "@types/graceful-fs": "^4.1.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index 716d0175bfc0..ec713ddac740 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -23,7 +23,7 @@ "collect-v8-coverage": "^1.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-test-sequencer/package.json b/packages/jest-test-sequencer/package.json index ada707def276..de25c848aee9 100644 --- a/packages/jest-test-sequencer/package.json +++ b/packages/jest-test-sequencer/package.json @@ -26,7 +26,7 @@ "@types/graceful-fs": "^4.1.3" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-transform/package.json b/packages/jest-transform/package.json index f312bed631cc..0853c7829e56 100644 --- a/packages/jest-transform/package.json +++ b/packages/jest-transform/package.json @@ -44,7 +44,7 @@ "dedent": "^0.7.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index b2bc556b2c29..b7fce84e5ae1 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -7,7 +7,7 @@ "directory": "packages/jest-types" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "license": "MIT", "main": "./build/index.js", diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 842e2b9d322e..c6b3e2516c76 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -30,7 +30,7 @@ "@types/picomatch": "^2.2.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-validate/package.json b/packages/jest-validate/package.json index 5f3182127152..d7392a6dcbe5 100644 --- a/packages/jest-validate/package.json +++ b/packages/jest-validate/package.json @@ -28,7 +28,7 @@ "@types/yargs": "^16.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index bd8d3833fe8d..9fdee8a5658f 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -29,7 +29,7 @@ "url": "https://github.com/facebook/jest/issues" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "homepage": "https://jestjs.io/", "license": "MIT", diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index 98fc83fa12e3..8262e528081d 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -29,7 +29,7 @@ "worker-farm": "^1.6.0" }, "engines": { - "node": ">= 10.13.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-worker/src/workers/NodeThreadsWorker.ts b/packages/jest-worker/src/workers/NodeThreadsWorker.ts index 136b648c33de..ab125664848b 100644 --- a/packages/jest-worker/src/workers/NodeThreadsWorker.ts +++ b/packages/jest-worker/src/workers/NodeThreadsWorker.ts @@ -61,7 +61,6 @@ export default class ExperimentalWorker implements WorkerInterface { initialize(): void { this._worker = new Worker(path.resolve(__dirname, './threadChild.js'), { eval: false, - // @ts-expect-error: added in newer versions resourceLimits: this._options.resourceLimits, stderr: true, stdout: true, diff --git a/packages/jest/package.json b/packages/jest/package.json index 26141b102c94..e03d8287cd05 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -27,7 +27,7 @@ }, "bin": "./bin/jest.js", "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "repository": { "type": "git", diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index 5b51e8d14623..3d0d5539dfd7 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -35,7 +35,7 @@ "react-test-renderer": "*" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 8be0fd9a99e5..2f71ba81b5ca 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -24,6 +24,6 @@ "@types/semver": "^7.1.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" } } diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index 6a8b79298f61..08f04b04863b 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -35,8 +35,7 @@ module.exports.getPackages = function getPackages() { assert.strictEqual( pkg.engines.node, - // TODO: remove special casing for Jest 28 - pkg.name === 'jest-worker' ? '>= 10.13.0' : nodeEngineRequirement, + nodeEngineRequirement, `Engine requirement in ${pkg.name} should match root`, ); diff --git a/tsconfig.json b/tsconfig.json index 0285f916ae72..90c8a266d483 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,6 @@ { - "extends": "@tsconfig/node10/tsconfig.json", + "extends": "@tsconfig/node12/tsconfig.json", "compilerOptions": { - // Object.fromEntries - "lib": ["es2019.object"], "declaration": true, "composite": true, "emitDeclarationOnly": true, diff --git a/yarn.lock b/yarn.lock index e6d2b2275fb8..127b9ff34e9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2599,14 +2599,14 @@ __metadata: "@crowdin/cli": ^3.5.2 "@jest/globals": "workspace:*" "@jest/test-utils": "workspace:*" - "@tsconfig/node10": ^1.0.8 + "@tsconfig/node12": ^1.0.9 "@tsd/typescript": ~4.1.5 "@types/babel__core": ^7.0.0 "@types/babel__generator": ^7.0.0 "@types/babel__template": ^7.0.0 "@types/dedent": 0.7.0 "@types/jest": ^26.0.15 - "@types/node": ~10.14.0 + "@types/node": ~12.12.0 "@types/which": ^2.0.0 "@typescript-eslint/eslint-plugin": ^4.1.0 "@typescript-eslint/parser": ^4.1.0 @@ -4464,10 +4464,10 @@ __metadata: languageName: node linkType: hard -"@tsconfig/node10@npm:^1.0.8": - version: 1.0.8 - resolution: "@tsconfig/node10@npm:1.0.8" - checksum: 0336493b89fb7c06409a1247a3fb00fac2755f21f3f8ae4b9dd2457859abfc5e8ca42b6d9ca5a279fe81bc70fe1f3450eef61e5dd5a63a7b4a6946ff31874816 +"@tsconfig/node12@npm:^1.0.9": + version: 1.0.9 + resolution: "@tsconfig/node12@npm:1.0.9" + checksum: 5532bfb5df47ed3a507da533c731a2fb80ee2e886edadbf20e664dcd3172d5c159577a281d15733b8d0c30bfa4e6b48496bef0704192c085520bc76bb9938068 languageName: node linkType: hard @@ -4928,17 +4928,17 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:~10.14.0": - version: 10.14.22 - resolution: "@types/node@npm:10.14.22" - checksum: 392965766fc7f221169d62e4dafbfc875ba172ce610ac48fec26eaf572386913bd2c5d2e036bb747bb49923f1ade9eed2b2d09a391cbf5fbaaa864a74a4dad60 +"@types/node@npm:*, @types/node@npm:~12.12.0": + version: 12.12.70 + resolution: "@types/node@npm:12.12.70" + checksum: ef0ea535b8301d7d8f89d848bb7d5028bbd702d8d96b812100cba71829b460fc0d00cbbf296909254c49d0efe5a57dd37d40ba3abaca902dc170034e90f651a2 languageName: node linkType: hard "@types/node@npm:^14.0.27": - version: 14.18.3 - resolution: "@types/node@npm:14.18.3" - checksum: 6e592ab47ced8c54f0bc8036e11fbd40581025d2c7cc477bb85486eea41027d946d0495311a8f2f2137b4caf0500bf74813257ee2adecb51a2ed507bae0d224b + version: 14.18.10 + resolution: "@types/node@npm:14.18.10" + checksum: c5a7abb126c8d08b215193500ce7d061ac8191f21c712c9b9e35356b8fd7b6b47ac8887b459deba161b4d310962706a623e0e919798cc932a75623894a4e3a3f languageName: node linkType: hard From 0713131378768a12929b6151240507ce60c4c0e0 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 5 Feb 2022 12:11:53 +0100 Subject: [PATCH 2/6] simplify some code now that we do not support node 10 --- .../src/crawlers/__tests__/node.test.js | 168 ++++++------------ packages/jest-haste-map/src/crawlers/node.ts | 24 +-- packages/jest-resolve/src/isBuiltinModule.ts | 7 +- .../src/__tests__/process-integration.test.js | 6 - .../jest-worker/src/workers/messageParent.ts | 20 +-- 5 files changed, 71 insertions(+), 154 deletions(-) diff --git a/packages/jest-haste-map/src/crawlers/__tests__/node.test.js b/packages/jest-haste-map/src/crawlers/__tests__/node.test.js index d9b8229a285b..1d10eea8cf20 100644 --- a/packages/jest-haste-map/src/crawlers/__tests__/node.test.js +++ b/packages/jest-haste-map/src/crawlers/__tests__/node.test.js @@ -34,8 +34,6 @@ jest.mock('child_process', () => ({ }), })); -let mockHasReaddirWithFileTypesSupport = false; - jest.mock('graceful-fs', () => { const slash = require('slash'); let mtime = 32; @@ -73,55 +71,42 @@ jest.mock('graceful-fs', () => { throw new Error('readdir: callback is not a function!'); } - if (mockHasReaddirWithFileTypesSupport) { - if (slash(dir) === '/project/fruits') { - setTimeout( - () => - callback(null, [ - { - isDirectory: () => true, - isSymbolicLink: () => false, - name: 'directory', - }, - { - isDirectory: () => false, - isSymbolicLink: () => false, - name: 'tomato.js', - }, - { - isDirectory: () => false, - isSymbolicLink: () => true, - name: 'symlink', - }, - ]), - 0, - ); - } else if (slash(dir) === '/project/fruits/directory') { - setTimeout( - () => - callback(null, [ - { - isDirectory: () => false, - isSymbolicLink: () => false, - name: 'strawberry.js', - }, - ]), - 0, - ); - } else if (slash(dir) == '/error') { - setTimeout(() => callback({code: 'ENOTDIR'}, undefined), 0); - } - } else { - if (slash(dir) === '/project/fruits') { - setTimeout( - () => callback(null, ['directory', 'tomato.js', 'symlink']), - 0, - ); - } else if (slash(dir) === '/project/fruits/directory') { - setTimeout(() => callback(null, ['strawberry.js']), 0); - } else if (slash(dir) == '/error') { - setTimeout(() => callback({code: 'ENOTDIR'}, undefined), 0); - } + if (slash(dir) === '/project/fruits') { + setTimeout( + () => + callback(null, [ + { + isDirectory: () => true, + isSymbolicLink: () => false, + name: 'directory', + }, + { + isDirectory: () => false, + isSymbolicLink: () => false, + name: 'tomato.js', + }, + { + isDirectory: () => false, + isSymbolicLink: () => true, + name: 'symlink', + }, + ]), + 0, + ); + } else if (slash(dir) === '/project/fruits/directory') { + setTimeout( + () => + callback(null, [ + { + isDirectory: () => false, + isSymbolicLink: () => false, + name: 'strawberry.js', + }, + ]), + 0, + ); + } else if (slash(dir) == '/error') { + setTimeout(() => callback({code: 'ENOTDIR'}, undefined), 0); } }), stat: jest.fn(stat), @@ -379,65 +364,30 @@ describe('node crawler', () => { expect(removedFiles).toEqual(new Map()); }); - describe('readdir withFileTypes support', () => { - it('calls lstat for directories and symlinks if readdir withFileTypes is not supported', async () => { - nodeCrawl = require('../node'); - const fs = require('graceful-fs'); - - const files = new Map(); - const {hasteMap, removedFiles} = await nodeCrawl({ - data: {files}, - extensions: ['js'], - forceNodeFilesystemAPI: true, - ignore: pearMatcher, - rootDir, - roots: ['/project/fruits'], - }); - - expect(hasteMap.files).toEqual( - createMap({ - 'fruits/directory/strawberry.js': ['', 33, 42, 0, '', null], - 'fruits/tomato.js': ['', 32, 42, 0, '', null], - }), - ); - expect(removedFiles).toEqual(new Map()); - // once for /project/fruits, once for /project/fruits/directory - expect(fs.readdir).toHaveBeenCalledTimes(2); - // once for each of: - // 1. /project/fruits/directory - // 2. /project/fruits/directory/strawberry.js - // 3. /project/fruits/tomato.js - // 4. /project/fruits/symlink - // (we never call lstat on the root /project/fruits, since we know it's a directory) - expect(fs.lstat).toHaveBeenCalledTimes(4); - }); + it('avoids calling lstat for directories and symlinks', async () => { + nodeCrawl = require('../node'); + const fs = require('graceful-fs'); - it('avoids calling lstat for directories and symlinks if readdir withFileTypes is supported', async () => { - mockHasReaddirWithFileTypesSupport = true; - nodeCrawl = require('../node'); - const fs = require('graceful-fs'); - - const files = new Map(); - const {hasteMap, removedFiles} = await nodeCrawl({ - data: {files}, - extensions: ['js'], - forceNodeFilesystemAPI: true, - ignore: pearMatcher, - rootDir, - roots: ['/project/fruits'], - }); - - expect(hasteMap.files).toEqual( - createMap({ - 'fruits/directory/strawberry.js': ['', 33, 42, 0, '', null], - 'fruits/tomato.js': ['', 32, 42, 0, '', null], - }), - ); - expect(removedFiles).toEqual(new Map()); - // once for /project/fruits, once for /project/fruits/directory - expect(fs.readdir).toHaveBeenCalledTimes(2); - // once for strawberry.js, once for tomato.js - expect(fs.lstat).toHaveBeenCalledTimes(2); + const files = new Map(); + const {hasteMap, removedFiles} = await nodeCrawl({ + data: {files}, + extensions: ['js'], + forceNodeFilesystemAPI: true, + ignore: pearMatcher, + rootDir, + roots: ['/project/fruits'], }); + + expect(hasteMap.files).toEqual( + createMap({ + 'fruits/directory/strawberry.js': ['', 33, 42, 0, '', null], + 'fruits/tomato.js': ['', 32, 42, 0, '', null], + }), + ); + expect(removedFiles).toEqual(new Map()); + // once for /project/fruits, once for /project/fruits/directory + expect(fs.readdir).toHaveBeenCalledTimes(2); + // once for strawberry.js, once for tomato.js + expect(fs.lstat).toHaveBeenCalledTimes(2); }); }); diff --git a/packages/jest-haste-map/src/crawlers/node.ts b/packages/jest-haste-map/src/crawlers/node.ts index 58fc9ccf442d..88d15678706d 100644 --- a/packages/jest-haste-map/src/crawlers/node.ts +++ b/packages/jest-haste-map/src/crawlers/node.ts @@ -74,27 +74,19 @@ function find( callback(result); return; } - // node < v10.10 does not support the withFileTypes option, and - // entry will be a string. - entries.forEach((entry: string | fs.Dirent) => { - const file = path.join( - directory, - typeof entry === 'string' ? entry : entry.name, - ); + entries.forEach(entry => { + const file = path.join(directory, entry.name); if (ignore(file)) { return; } - if (typeof entry !== 'string') { - if (entry.isSymbolicLink()) { - return; - } - - if (entry.isDirectory()) { - search(file); - return; - } + if (entry.isSymbolicLink()) { + return; + } + if (entry.isDirectory()) { + search(file); + return; } activeCalls++; diff --git a/packages/jest-resolve/src/isBuiltinModule.ts b/packages/jest-resolve/src/isBuiltinModule.ts index df64cc3d422f..a80fa949e540 100644 --- a/packages/jest-resolve/src/isBuiltinModule.ts +++ b/packages/jest-resolve/src/isBuiltinModule.ts @@ -7,12 +7,7 @@ import module = require('module'); -// TODO: remove when we drop support for node v10 - it is included from node v12 -const EXPERIMENTAL_MODULES = ['worker_threads']; - -const BUILTIN_MODULES = new Set( - module.builtinModules.concat(EXPERIMENTAL_MODULES), -); +const BUILTIN_MODULES = new Set(module.builtinModules); export default function isBuiltinModule(module: string): boolean { return BUILTIN_MODULES.has(module); diff --git a/packages/jest-worker/src/__tests__/process-integration.test.js b/packages/jest-worker/src/__tests__/process-integration.test.js index 50fffc721e17..d5e3f0950504 100644 --- a/packages/jest-worker/src/__tests__/process-integration.test.js +++ b/packages/jest-worker/src/__tests__/process-integration.test.js @@ -5,8 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -'use strict'; - import EventEmitter from 'events'; import {CHILD_MESSAGE_CALL, PARENT_MESSAGE_OK} from '../types'; @@ -37,10 +35,6 @@ function assertCallsToChild(childNum, ...calls) { }); } -jest.mock('worker_threads', () => { - throw Error('Unsupported'); -}); - describe('Jest Worker Integration', () => { beforeEach(() => { mockForkedProcesses = []; diff --git a/packages/jest-worker/src/workers/messageParent.ts b/packages/jest-worker/src/workers/messageParent.ts index d4a389055fc0..8c9127395aa6 100644 --- a/packages/jest-worker/src/workers/messageParent.ts +++ b/packages/jest-worker/src/workers/messageParent.ts @@ -5,29 +5,15 @@ * LICENSE file in the root directory of this source tree. */ +import {isMainThread, parentPort} from 'worker_threads'; import {PARENT_MESSAGE_CUSTOM} from '../types'; -const isWorkerThread: boolean = (() => { - try { - // `Require` here to support Node v10 - const {isMainThread, parentPort} = - require('worker_threads') as typeof import('worker_threads'); - return !isMainThread && parentPort != null; - } catch { - return false; - } -})(); - export default function messageParent( message: unknown, parentProcess = process, ): void { - if (isWorkerThread) { - // `Require` here to support Node v10 - const {parentPort} = - require('worker_threads') as typeof import('worker_threads'); - // ! is safe due to `null` check in `isWorkerThread` - parentPort!.postMessage([PARENT_MESSAGE_CUSTOM, message]); + if (!isMainThread && parentPort != null) { + parentPort.postMessage([PARENT_MESSAGE_CUSTOM, message]); } else if (typeof parentProcess.send === 'function') { parentProcess.send([PARENT_MESSAGE_CUSTOM, message]); } else { From 040193dd8827f2d4c350d773531b1546f3de41e1 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 08:30:44 +0100 Subject: [PATCH 3/6] quotes --- scripts/buildUtils.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index 08f04b04863b..b645f5ac8531 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -31,15 +31,18 @@ module.exports.getPackages = function getPackages() { return packages.map(packageDir => { const pkg = readPkg({cwd: packageDir}); - assert.ok(pkg.engines, `Engine requirement in ${pkg.name} should exist`); + assert.ok(pkg.engines, `Engine requirement in "${pkg.name}" should exist`); assert.strictEqual( pkg.engines.node, nodeEngineRequirement, - `Engine requirement in ${pkg.name} should match root`, + `Engine requirement in "${pkg.name}" should match root`, ); - assert.ok(pkg.exports, `Package ${pkg.name} is missing \`exports\` field`); + assert.ok( + pkg.exports, + `Package "${pkg.name}" is missing \`exports\` field`, + ); assert.deepStrictEqual( pkg.exports, { @@ -68,7 +71,7 @@ module.exports.getPackages = function getPackages() { ? {'./ConvertAnsi': './build/plugins/ConvertAnsi.js'} : {}), }, - `Package ${pkg.name} does not export correct files`, + `Package "${pkg.name}" does not export correct files`, ); if (pkg.bin) { @@ -77,7 +80,7 @@ module.exports.getPackages = function getPackages() { if (!fs.existsSync(fullBinPath)) { throw new Error( - `Binary in package ${pkg.name} with name "${binName}" at ${binPath} does not exist`, + `Binary in package "${pkg.name}" with name "${binName}" at ${binPath} does not exist`, ); } }); From 7f644e3782343609acfaa0542833ab64d56049c4 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 08:49:01 +0100 Subject: [PATCH 4/6] update snaps --- e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap | 4 ++-- .../__snapshots__/resolveNoFileExtensions.test.ts.snap | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap b/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap index 08021660bd7e..b756a376579a 100644 --- a/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap +++ b/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap @@ -41,7 +41,7 @@ exports[`moduleNameMapper wrong array configuration 1`] = ` 12 | module.exports = () => 'test'; 13 | - at createNoMappedModuleFoundError (../../packages/jest-resolve/build/resolver.js:579:17) + at createNoMappedModuleFoundError (../../packages/jest-resolve/build/resolver.js:568:17) at Object.require (index.js:10:1)" `; @@ -70,6 +70,6 @@ exports[`moduleNameMapper wrong configuration 1`] = ` 12 | module.exports = () => 'test'; 13 | - at createNoMappedModuleFoundError (../../packages/jest-resolve/build/resolver.js:579:17) + at createNoMappedModuleFoundError (../../packages/jest-resolve/build/resolver.js:568:17) at Object.require (index.js:10:1)" `; diff --git a/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap b/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap index b4a32a33567d..00bb293f258e 100644 --- a/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap +++ b/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap @@ -37,6 +37,6 @@ exports[`show error message with matching files 1`] = ` | ^ 9 | - at Resolver.resolveModule (../../packages/jest-resolve/build/resolver.js:324:11) + at Resolver.resolveModule (../../packages/jest-resolve/build/resolver.js:317:11) at Object.require (index.js:8:18)" `; From a7fb48588d3e37bcbd2b982d279a18b41f9ac204 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 08:52:24 +0100 Subject: [PATCH 5/6] simplify config --- jest.config.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/jest.config.js b/jest.config.js index 15d7bd48491b..c54992993b8a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -34,10 +34,7 @@ module.exports = { snapshotFormat: { escapeString: false, }, - snapshotSerializers: [ - // change to require.resolve('pretty-format/ConvertAnsi') when we drop Node 10 - '/packages/pretty-format/build/plugins/ConvertAnsi.js', - ], + snapshotSerializers: [require.resolve('pretty-format/ConvertAnsi')], testPathIgnorePatterns: [ '/__arbitraries__/', '/__typetests__/', From 807c95ec944d6a7c397ce91f69e5ed35058eb25f Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 09:23:53 +0100 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 358f7b4f11b2..88e1df1ab09c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Chore & Maintenance -- `[*]` Drop support for Node v10 and v15 and target first LTS `16.13.0` ([#12220](https://github.com/facebook/jest/pull/12220)) +- `[*]` [**BREAKING**] Drop support for Node v10 and v15 and target first LTS `16.13.0` ([#12220](https://github.com/facebook/jest/pull/12220)) ### Performance