11import { describe , it , expect } from '@jest/globals' ;
2- import { exec } from 'node:child_process' ;
2+ import { execFile } from 'node:child_process' ;
33import path from 'node:path' ;
44import process from 'node:process' ;
55
@@ -8,13 +8,15 @@ const cliPath = path.resolve(__dirname, '../dist/cli.js');
88const doIntegration = process . env [ 'TEST_INTEGRATION' ] ?. toLowerCase ( ) === 'true' ;
99const doRemote = process . env [ 'TEST_REMOTE' ] ?. toLowerCase ( ) === 'true' ;
1010
11+ const url = process . env [ 'TEST_LI_URL' ] || 'http://localhost:3000' ;
12+
1113const describeIntegration = doIntegration ? describe : describe . skip ;
1214// const describeRemote = doRemote ? describe : describe.skip;
1315const itRemote = doRemote ? it : it . skip ;
1416
1517describeIntegration ( 'CLI Integration Tests' , ( ) => {
1618 it ( 'should show help with no arguments' , ( done ) => {
17- exec ( ` node ${ cliPath } ` , ( error , stdout , stderr ) => {
19+ execFile ( ' node' , [ cliPath ] , ( error , stdout , stderr ) => {
1820 expect ( stderr ) . toContain ( ' <command>' ) ;
1921 expect ( stderr ) . toContain ( 'Not enough non-option arguments' ) ;
2022 expect ( stderr ) . toContain ( ' add-license ' ) ;
@@ -24,24 +26,25 @@ describeIntegration('CLI Integration Tests', () => {
2426
2527 describeIntegration ( 'add-license' , ( ) => {
2628 it ( '--help' , ( done ) => {
27- exec ( ` node ${ cliPath } add-license --help` , ( error , stdout ) => {
29+ execFile ( ' node' , [ cliPath , ' add-license' , ' --help' ] , ( error , stdout ) => {
2830 expect ( stdout ) . toContain ( ' add-license ' ) ;
2931 expect ( stdout ) . toContain ( '--require-cal' ) ;
3032 done ( ) ;
3133 } ) ;
3234 } ) ;
3335
3436 it ( 'should require --li-url' , ( done ) => {
35- exec ( ` node ${ cliPath } add-license` , ( error , stdout , stderr ) => {
37+ execFile ( ' node' , [ cliPath , ' add-license' ] , ( error , stdout , stderr ) => {
3638 expect ( stderr ) . toContain ( 'Missing required argument: li-url' ) ;
3739 expect ( stderr ) . toContain ( '--require-cal' ) ;
3840 done ( ) ;
3941 } ) ;
4042 } ) ;
4143
4244 itRemote ( 'should apply a license' , ( done ) => {
43- exec (
44- `node ${ cliPath } add-license --li-url http://localhost:3000 apache-2.0` ,
45+ execFile (
46+ 'node' ,
47+ [ cliPath , 'add-license' , '--li-url' , url , 'apache-2.0' ] ,
4548 ( error , stdout , stderr ) => {
4649 expect ( stdout ) . toContain ( 'fetching license list' ) ;
4750 expect ( stdout ) . toContain ( 'Choose A License info' ) ;
0 commit comments