@@ -261,17 +261,38 @@ test.suite('esm', (test) => {
261
261
test . suite ( 'supports import assertions' , ( test ) => {
262
262
test . runIf ( nodeSupportsImportAssertions ) ;
263
263
264
- test ( 'Can import JSON using the appropriate flag and assertion' , async ( t ) => {
265
- const { err, stdout } = await exec (
266
- `${ CMD_ESM_LOADER_WITHOUT_PROJECT } --experimental-json-modules ./importJson.ts` ,
267
- {
268
- cwd : resolve ( TEST_DIR , 'esm-import-assertions' ) ,
269
- }
270
- ) ;
271
- expect ( err ) . toBe ( null ) ;
272
- expect ( stdout . trim ( ) ) . toBe (
273
- 'A fuchsia car has 2 seats and the doors are open.\nDone!'
274
- ) ;
264
+ test . suite ( 'node >=17.5.0' , ( test ) => {
265
+ test . runIf ( semver . gte ( process . version , '17.5.0' ) ) ;
266
+
267
+ test ( 'Can import JSON modules with appropriate assertion' , async ( t ) => {
268
+ const { err, stdout } = await exec (
269
+ `${ CMD_ESM_LOADER_WITHOUT_PROJECT } ./importJson.ts` ,
270
+ {
271
+ cwd : resolve ( TEST_DIR , 'esm-import-assertions' ) ,
272
+ }
273
+ ) ;
274
+ expect ( err ) . toBe ( null ) ;
275
+ expect ( stdout . trim ( ) ) . toBe (
276
+ 'A fuchsia car has 2 seats and the doors are open.\nDone!'
277
+ ) ;
278
+ } ) ;
279
+ } ) ;
280
+
281
+ test . suite ( 'node <17.5.0' , ( test ) => {
282
+ test . runIf ( semver . lt ( process . version , '17.5.0' ) ) ;
283
+
284
+ test ( 'Can import JSON using the appropriate flag and assertion' , async ( t ) => {
285
+ const { err, stdout } = await exec (
286
+ `${ CMD_ESM_LOADER_WITHOUT_PROJECT } --experimental-json-modules ./importJson.ts` ,
287
+ {
288
+ cwd : resolve ( TEST_DIR , 'esm-import-assertions' ) ,
289
+ }
290
+ ) ;
291
+ expect ( err ) . toBe ( null ) ;
292
+ expect ( stdout . trim ( ) ) . toBe (
293
+ 'A fuchsia car has 2 seats and the doors are open.\nDone!'
294
+ ) ;
295
+ } ) ;
275
296
} ) ;
276
297
} ) ;
277
298
0 commit comments