Skip to content

Commit 02b60df

Browse files
Revert "Split Node.js 18 and Node.js 20+ tests in two files"
This reverts commit a20cb5c.
1 parent a1b6901 commit 02b60df

File tree

9 files changed

+29
-324
lines changed

9 files changed

+29
-324
lines changed

jest.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ export default {
6868
'/packages/jest-snapshot/src/__tests__/fixtures/',
6969
'/e2e/__tests__/iterator-to-null-test.ts',
7070
'/e2e/__tests__/tsIntegration.test.ts', // this test needs types to be build, it runs in a separate CI job through `jest.config.ts.mjs`
71-
Number.parseInt(process.versions.node, 10) >= 20
72-
? '/.*\\.nodejs18\\..*'
73-
: '/.*\\.nodejs20plus\\..*',
7471
],
7572
testTimeout: 70_000,
7673
transform: {

packages/babel-plugin-jest-hoist/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@babel/preset-react": "^7.27.1",
3333
"@babel/preset-typescript": "^7.27.1",
3434
"@babel/types": "^7.27.3",
35+
"@jest/test-utils": "workspace:*",
3536
"@prettier/sync": "^0.5.5",
3637
"@types/babel__template": "^7.4.4",
3738
"@types/babel__traverse": "^7.20.7",

packages/babel-plugin-jest-hoist/src/__tests__/__snapshots__/hoistPlugin.nodejs18.test.ts.snap

Lines changed: 0 additions & 288 deletions
This file was deleted.

packages/babel-plugin-jest-hoist/src/__tests__/hoistPlugin.nodejs20plus.test.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/babel-plugin-jest-hoist/src/__tests__/hoistPlugin.nodejs18.test.ts renamed to packages/babel-plugin-jest-hoist/src/__tests__/hoistPlugin.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@
99
import * as path from 'path';
1010
import {format as formatCode, resolveConfig} from '@prettier/sync';
1111
import pluginTester from 'babel-plugin-tester';
12+
import {onNodeVersions} from '@jest/test-utils';
1213
import type {Options} from 'prettier';
1314
import babelPluginJestHoist from '..';
1415

16+
// We need to use the Node.js implementation of `require` to load Babel 8
17+
// packages, instead of our sandboxed implementation, because Babel 8 is
18+
// written in ESM and we don't support require(esm) yet.
19+
import Module from 'node:module';
20+
import {pathToFileURL} from 'node:url';
21+
const createOriginalNodeRequire = Object.getPrototypeOf(Module).createRequire;
22+
const originalNodeRequire = createOriginalNodeRequire(
23+
pathToFileURL(__filename),
24+
);
25+
1526
const prettierOptions: Options = {
1627
...resolveConfig(__filename),
1728
filepath: __filename,
@@ -28,7 +39,18 @@ describe('babel 7', () => {
2839
});
2940
});
3041

31-
export function defineTests({
42+
describe('babel 8', () => {
43+
onNodeVersions('>=20', skipped => {
44+
const req = skipped ? () => null : originalNodeRequire;
45+
defineTests({
46+
babel: req('@babel-8/core'),
47+
presetReact: req('@babel-8/preset-react'),
48+
presetTypescript: req('@babel-8/preset-typescript'),
49+
});
50+
});
51+
});
52+
53+
function defineTests({
3254
babel,
3355
presetReact,
3456
presetTypescript,

packages/babel-plugin-jest-hoist/src/__tests__/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"compilerOptions": {
55
"types": ["node", "@jest/test-globals"]
66
},
7-
"references": [{"path": "../../"}]
7+
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
88
}

0 commit comments

Comments
 (0)