Skip to content

Commit

Permalink
chore: drop node 10 and node 15
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 5, 2022
1 parent 9bcd565 commit fd3adba
Show file tree
Hide file tree
Showing 65 changed files with 130 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -70,5 +70,5 @@ workflows:
partial: true
matrix:
parameters:
node-version: ['10', '12', '15', '16', '17']
node-version: ['12', '16', '17']
- test-jest-jasmine
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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.0
Expand Down
16 changes: 1 addition & 15 deletions e2e/__tests__/consoleLogOutputWhenRunInBand.test.ts
Expand Up @@ -15,8 +15,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': `
Expand All @@ -25,26 +23,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.<anonymous>.test (__tests__/a-banana.js:1:1)',
);

stdout = stdout.replace(
'at Object.<anonymous>.test (__tests__/a-banana.js:1:1)',
'at Object.<anonymous> (__tests__/a-banana.js:1:1)',
);
}

expect(exitCode).toBe(0);
expect(wrap(rest)).toMatchSnapshot();
expect(wrap(summary)).toMatchSnapshot();
Expand Down
35 changes: 15 additions & 20 deletions e2e/__tests__/detectOpenHandles.ts
Expand Up @@ -6,7 +6,6 @@
*/

import {wrap} from 'jest-snapshot-serializer-raw';
import {onNodeVersions} from '@jest/test-utils';
import runJest, {runContinuous} from '../runJest';

try {
Expand Down Expand Up @@ -82,16 +81,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', () => {
Expand All @@ -110,17 +107,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 () => {
Expand Down
18 changes: 1 addition & 17 deletions e2e/__tests__/errorOnDeprecated.test.ts
Expand Up @@ -32,30 +32,14 @@ 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', [
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.<anonymous>.test ${lineEntry}`);

rest = rest.replace(
`at Object.<anonymous>.test ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}
const {rest} = extractSummary(result.stderr);

expect(wrap(rest)).toMatchSnapshot();
});
Expand Down
14 changes: 0 additions & 14 deletions e2e/__tests__/failures.test.ts
Expand Up @@ -21,8 +21,6 @@ function cleanStderr(stderr: string) {
.replace(new RegExp('Failed: Object {', 'g'), 'thrown: Object {');
}

const nodeMajorVersion = Number(process.versions.node.split('.')[0]);

beforeAll(() => {
runYarnInstall(dir);
});
Expand All @@ -38,18 +36,6 @@ test('not throwing Error objects', () => {
stderr = runJest(dir, ['assertionCount.test.js']).stderr;
expect(wrap(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.<anonymous>.done ${lineEntry}`);

stderr = stderr.replace(
`at Object.<anonymous>.done ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}

expect(wrap(cleanStderr(stderr))).toMatchSnapshot();
stderr = runJest(dir, ['throwObjectWithStackProp.test.js']).stderr;
expect(wrap(cleanStderr(stderr))).toMatchSnapshot();
Expand Down
20 changes: 9 additions & 11 deletions e2e/__tests__/requireMainAfterCreateRequire.test.ts
Expand Up @@ -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',
),
);
});
11 changes: 3 additions & 8 deletions e2e/__tests__/unexpectedToken.test.ts
Expand Up @@ -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));
Expand Down Expand Up @@ -51,13 +50,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', () => {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -13,14 +13,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",
Expand Down Expand Up @@ -147,7 +147,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:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-jest/package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-jest-hoist/package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-jest/package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/diff-sequences/package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-changed-files/package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/package.json
Expand Up @@ -50,7 +50,7 @@
"jest-snapshot-serializer-raw": "^1.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"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-console/package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/package.json
Expand Up @@ -59,7 +59,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",
Expand Down
5 changes: 2 additions & 3 deletions packages/jest-core/src/collectHandles.ts
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-create-cache-key-function/package.json
Expand Up @@ -14,7 +14,7 @@
"jest-util": "^27.5.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"
},
"license": "MIT",
"main": "./build/index.js",
Expand Down

0 comments on commit fd3adba

Please sign in to comment.