Skip to content

Commit ded24ce

Browse files
committed
merge fixes
1 parent e599bad commit ded24ce

File tree

2 files changed

+26
-55
lines changed

2 files changed

+26
-55
lines changed

src/test/esm-loader.spec.ts

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -255,58 +255,35 @@ test.suite('esm', (test) => {
255255
});
256256

257257
test.suite('supports import assertions', (test) => {
258-
test.runIf(nodeSupportsImportAssertions);
258+
test.runIf(nodeSupportsImportAssertions && tsSupportsImportAssertions);
259259

260-
test.suite('node >=17.5.0', (test) => {
261-
test.runIf(semver.gte(process.version, '17.5.0'));
262-
263-
test('Can import JSON modules with appropriate assertion', async (t) => {
264-
const { err, stdout } = await exec(
265-
`${CMD_ESM_LOADER_WITHOUT_PROJECT} ./importJson.ts`,
266-
{
267-
cwd: resolve(TEST_DIR, 'esm-import-assertions'),
268-
}
269-
);
270-
expect(err).toBe(null);
271-
expect(stdout.trim()).toBe(
272-
'A fuchsia car has 2 seats and the doors are open.\nDone!'
273-
);
274-
});
275-
});
276-
277-
test.suite('supports import assertions', (test) => {
278-
test.runIf(
279-
nodeSupportsImportAssertions &&
280-
tsSupportsImportAssertions
260+
const macro = test.macro((flags: string) => async (t) => {
261+
const { err, stdout } = await exec(
262+
`${CMD_ESM_LOADER_WITHOUT_PROJECT} ${flags} ./importJson.ts`,
263+
{
264+
cwd: resolve(TEST_DIR, 'esm-import-assertions'),
265+
}
281266
);
267+
expect(err).toBe(null);
268+
expect(stdout.trim()).toBe(
269+
'A fuchsia car has 2 seats and the doors are open.\nDone!'
270+
);
271+
});
282272

283-
const macro = test.macro((flags: string) => async (t) => {
284-
const { err, stdout } = await exec(
285-
`${CMD_ESM_LOADER_WITHOUT_PROJECT} ${flags} ./importJson.ts`,
286-
{
287-
cwd: resolve(TEST_DIR, 'esm-import-assertions'),
288-
}
289-
);
290-
expect(err).toBe(null);
291-
expect(stdout.trim()).toBe(
292-
'A fuchsia car has 2 seats and the doors are open.\nDone!'
293-
);
294-
});
295-
296-
test.suite(
297-
'when node does not require --experimental-json-modules',
298-
(test) => {
299-
test.runIf(nodeSupportsUnflaggedJsonImports);
300-
test('Can import JSON modules with appropriate assertion', macro, '');
301-
}
273+
test.suite(
274+
'when node does not require --experimental-json-modules',
275+
(test) => {
276+
test.runIf(nodeSupportsUnflaggedJsonImports);
277+
test('Can import JSON modules with appropriate assertion', macro, '');
278+
}
279+
);
280+
test.suite('when node requires --experimental-json-modules', (test) => {
281+
test.runIf(!nodeSupportsUnflaggedJsonImports);
282+
test(
283+
'Can import JSON using the appropriate flag and assertion',
284+
macro,
285+
'--experimental-json-modules'
302286
);
303-
test.suite('when node requires --experimental-json-modules', (test) => {
304-
test.runIf(!nodeSupportsUnflaggedJsonImports);
305-
test(
306-
'Can import JSON using the appropriate flag and assertion',
307-
macro,
308-
'--experimental-json-modules'
309-
);
310287
});
311288
});
312289

src/test/module-node/1778.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { createExec } from '../exec-helpers';
22
import {
33
ctxTsNode,
4-
nodeSupportsEsmHooks,
54
TEST_DIR,
65
tsSupportsStableNodeNextNode16,
76
CMD_TS_NODE_WITHOUT_PROJECT_FLAG,
8-
nodeSupportsSpawningChildProcess,
97
} from '../helpers';
108
import { context, expect } from '../testlib';
119
import { join } from 'path';
@@ -19,11 +17,7 @@ const test = context(ctxTsNode);
1917
test.suite(
2018
'Issue #1778: typechecker resolver should take importer\'s module type -- cjs or esm -- into account when resolving package.json "exports"',
2119
(test) => {
22-
test.runIf(
23-
nodeSupportsEsmHooks &&
24-
nodeSupportsSpawningChildProcess &&
25-
tsSupportsStableNodeNextNode16
26-
);
20+
test.runIf(tsSupportsStableNodeNextNode16);
2721
test('test', async () => {
2822
const { err, stdout } = await exec(
2923
`${CMD_TS_NODE_WITHOUT_PROJECT_FLAG} ./index.ts`,

0 commit comments

Comments
 (0)