@@ -346,118 +346,6 @@ test('`test --json-file-output no value produces error message`', (t) => {
346
346
optionsToTest . forEach ( validate ) ;
347
347
} ) ;
348
348
349
- test ( '`test --json-file-output can save JSON output to file while sending human readable output to stdout`' , ( t ) => {
350
- t . plan ( 2 ) ;
351
- const tmpFolder = randomTmpFolderPath ( ) ;
352
- const jsonPath = path . normalize (
353
- `${ tmpFolder } /snyk-direct-json-test-output.json` ,
354
- ) ;
355
-
356
- const testFixture =
357
- 'test/acceptance/workspaces/npm-package-no-vulns/package.json' ;
358
-
359
- exec (
360
- `node ${ main } test --file=${ testFixture } --json-file-output=${ jsonPath } ` ,
361
- ( err , stdout ) => {
362
- if ( err ) {
363
- console . log ( 'CLI stdout: ' , stdout ) ;
364
- throw err ;
365
- }
366
- if ( ! existsSync ( jsonPath ) ) {
367
- console . log ( 'CLI stdout: ' , stdout ) ;
368
- }
369
- const outputFileContents = readFileSync ( jsonPath , 'utf-8' ) ;
370
- const jsonObj = JSON . parse ( outputFileContents ) ;
371
- const okValue = jsonObj . ok as boolean ;
372
-
373
- t . match ( stdout , 'Organization:' , 'contains human readable output' ) ;
374
- t . ok ( okValue , 'JSON output ok' ) ;
375
- } ,
376
- ) ;
377
- } ) ;
378
-
379
- test ( '`test --json-file-output produces same JSON output as normal JSON output to stdout`' , ( t ) => {
380
- t . plan ( 1 ) ;
381
- const tmpFolder = randomTmpFolderPath ( ) ;
382
- const jsonPath = path . normalize (
383
- `${ tmpFolder } /snyk-direct-json-test-output.json` ,
384
- ) ;
385
- const testFixture =
386
- 'test/acceptance/workspaces/npm-package-no-vulns/package.json' ;
387
- exec (
388
- `node ${ main } test --file=${ testFixture } --json --json-file-output=${ jsonPath } ` ,
389
- ( err , stdout ) => {
390
- if ( err ) {
391
- console . log ( 'CLI stdout: ' , stdout ) ;
392
- throw err ;
393
- }
394
- const stdoutJson = stdout ;
395
- if ( ! existsSync ( jsonPath ) ) {
396
- console . log ( 'CLI stdout: ' , stdout ) ;
397
- }
398
- const outputFileContents = readFileSync ( jsonPath , 'utf-8' ) ;
399
-
400
- t . equals ( stdoutJson , outputFileContents ) ;
401
- } ,
402
- ) ;
403
- } ) ;
404
-
405
- test ( '`test --json-file-output can handle a relative path`' , ( t ) => {
406
- t . plan ( 1 ) ;
407
- const tmpFolder = randomTmpFolderPath ( ) ;
408
- const outputPath = path . normalize (
409
- `${ tmpFolder } /snyk-direct-json-test-output.json` ,
410
- ) ;
411
- const testFixture =
412
- 'test/acceptance/workspaces/npm-package-no-vulns/package.json' ;
413
- exec (
414
- `node ${ main } test --file=${ testFixture } --json --json-file-output=${ outputPath } ` ,
415
- ( err , stdout ) => {
416
- if ( err ) {
417
- console . log ( 'CLI stdout: ' , stdout ) ;
418
- throw err ;
419
- }
420
- const stdoutJson = stdout ;
421
- if ( ! existsSync ( outputPath ) ) {
422
- console . log ( 'CLI stdout: ' , stdout ) ;
423
- }
424
- const outputFileContents = readFileSync ( outputPath , 'utf-8' ) ;
425
-
426
- t . equals ( stdoutJson , outputFileContents ) ;
427
- } ,
428
- ) ;
429
- } ) ;
430
-
431
- test (
432
- '`test --json-file-output can handle an absolute path`' ,
433
- { skip : isWindows } ,
434
- ( t ) => {
435
- t . plan ( 1 ) ;
436
- const tmpFolder = randomTmpFolderPath ( ) ;
437
- const outputPath = path . normalize (
438
- `${ tmpFolder } /snyk-direct-json-test-output.json` ,
439
- ) ;
440
- const testFixture =
441
- 'test/acceptance/workspaces/npm-package-no-vulns/package.json' ;
442
- exec (
443
- `node ${ main } test --file=${ testFixture } --json --json-file-output=${ outputPath } ` ,
444
- ( err , stdout ) => {
445
- if ( err ) {
446
- console . log ( 'CLI stdout: ' , stdout ) ;
447
- throw err ;
448
- }
449
- const stdoutJson = stdout ;
450
- if ( ! existsSync ( outputPath ) ) {
451
- console . log ( 'CLI stdout: ' , stdout ) ;
452
- }
453
- const outputFileContents = readFileSync ( outputPath , 'utf-8' ) ;
454
-
455
- t . equals ( stdoutJson , outputFileContents ) ;
456
- } ,
457
- ) ;
458
- } ,
459
- ) ;
460
-
461
349
test ( 'flags not allowed with --sarif' , ( t ) => {
462
350
t . plan ( 4 ) ;
463
351
exec ( `node ${ main } test iac --sarif --json` , ( err , stdout ) => {
0 commit comments