@@ -255,58 +255,35 @@ test.suite('esm', (test) => {
255
255
} ) ;
256
256
257
257
test . suite ( 'supports import assertions' , ( test ) => {
258
- test . runIf ( nodeSupportsImportAssertions ) ;
258
+ test . runIf ( nodeSupportsImportAssertions && tsSupportsImportAssertions ) ;
259
259
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
+ }
281
266
) ;
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
+ } ) ;
282
272
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'
302
286
) ;
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
- ) ;
310
287
} ) ;
311
288
} ) ;
312
289
0 commit comments