@@ -20,105 +20,91 @@ const spawnOpts: PromiseSpawnOptions = {
20
20
cwd : npmFixturesPath
21
21
}
22
22
23
- describe (
24
- 'Socket cdxgen command' ,
25
- {
26
- // Skip until we think of how to handle the output test.
27
- skip : true
28
- } ,
29
- async ( ) => {
30
- // Lazily access constants.rootBinPath.
31
- const entryPath = path . join ( constants . rootBinPath , `${ CLI } .js` )
23
+ describe ( 'Socket cdxgen command' , async ( ) => {
24
+ // Lazily access constants.rootBinPath.
25
+ const entryPath = path . join ( constants . rootBinPath , `${ CLI } .js` )
32
26
33
- it (
34
- 'should forwards known commands to cdxgen' ,
35
- {
36
- // Takes ~10s in CI
37
- timeout : 20_000
38
- } ,
39
- async ( ) => {
40
- for ( const command of [ '-h' , '--help' ] ) {
41
- // eslint-disable-next-line no-await-in-loop
42
- const ret = await spawn (
43
- // Lazily access constants.execPath.
44
- constants . execPath ,
45
- [ entryPath , 'cdxgen' , command ] ,
46
- spawnOpts
47
- )
48
- expect (
49
- ret . stdout . includes ( 'cdxgen' ) ,
50
- 'forwards commands to cdxgen'
51
- ) . toBe ( true )
52
- }
27
+ it (
28
+ 'should forwards known commands to cdxgen' ,
29
+ {
30
+ // Takes ~10s in CI
31
+ timeout : 20_000
32
+ } ,
33
+ async ( ) => {
34
+ for ( const command of [ '-h' , '--help' ] ) {
35
+ // eslint-disable-next-line no-await-in-loop
36
+ const ret = await spawn (
37
+ // Lazily access constants.execPath.
38
+ constants . execPath ,
39
+ [ entryPath , 'cdxgen' , '--yes' , command ] ,
40
+ spawnOpts
41
+ )
42
+ expect (
43
+ ret . stdout . includes ( 'cdxgen' ) ,
44
+ 'forwards commands to cdxgen'
45
+ ) . toBe ( true )
53
46
}
54
- )
47
+ }
48
+ )
55
49
56
- describe (
57
- 'command forwarding' ,
58
- {
59
- // Skip until we think of how to handle the output test.
60
- skip : true
61
- } ,
62
- async ( ) => {
63
- expect . extend ( {
64
- toHaveStderrStartWith ( received , expected ) {
65
- const { isNot } = this
66
- return {
67
- // do not alter your "pass" based on isNot. Vitest does it for you
68
- pass : received ?. stderr ?. startsWith ?.( expected ) ?? false ,
69
- message : ( ) =>
70
- `spawn.stderr did${ isNot ? ' not' : '' } start with \`${ expected } \`: ${ received ?. stderr } `
71
- }
72
- }
73
- } )
50
+ describe ( 'command forwarding' , async ( ) => {
51
+ expect . extend ( {
52
+ toHaveStderrInclude ( received , expected ) {
53
+ const { isNot } = this
54
+ return {
55
+ // do not alter your "pass" based on isNot. Vitest does it for you
56
+ pass : received ?. stderr ?. includes ?.( expected ) ?? false ,
57
+ message : ( ) =>
58
+ `spawn.stderr ${ isNot ? 'does NOT include' : 'includes' } \`${ expected } \`: ${ received ?. stderr } `
59
+ }
60
+ }
61
+ } )
74
62
75
- it ( 'should not forward -u to cdxgen' , async ( ) => {
76
- const command = '-u'
77
- await expect (
78
- ( ) =>
79
- spawn (
80
- // Lazily access constants.execPath.
81
- constants . execPath ,
82
- [ entryPath , 'cdxgen' , command ] ,
83
- spawnOpts
84
- )
85
- // @ts -ignore -- toHaveStderrStartWith is defined above
86
- ) . rejects . toHaveStderrStartWith (
87
- `${ LOG_SYMBOLS . fail } Unknown argument: ${ command } `
63
+ it ( 'should not forward -u to cdxgen' , async ( ) => {
64
+ const command = '-u'
65
+ await expect (
66
+ ( ) =>
67
+ spawn (
68
+ // Lazily access constants.execPath.
69
+ constants . execPath ,
70
+ [ entryPath , 'cdxgen' , '-y' , command ] ,
71
+ spawnOpts
88
72
)
89
- } )
73
+ // @ts -ignore -- toHaveStderrInclude is defined above
74
+ ) . rejects . toHaveStderrInclude (
75
+ `${ LOG_SYMBOLS . fail } Unknown argument: ${ command } `
76
+ )
77
+ } )
90
78
91
- it ( 'should not forward --unknown to cdxgen' , async ( ) => {
92
- const command = '--unknown'
93
- await expect (
94
- ( ) =>
95
- spawn (
96
- // Lazily access constants.execPath.
97
- constants . execPath ,
98
- [ entryPath , 'cdxgen' , command ] ,
99
- spawnOpts
100
- )
101
- // @ts -ignore -- toHaveStderrStartWith is defined above
102
- ) . rejects . toHaveStderrStartWith (
103
- `${ LOG_SYMBOLS . fail } Unknown argument: ${ command } `
79
+ it ( 'should not forward --unknown to cdxgen' , async ( ) => {
80
+ const command = '--unknown'
81
+ await expect (
82
+ ( ) =>
83
+ spawn (
84
+ // Lazily access constants.execPath.
85
+ constants . execPath ,
86
+ [ entryPath , 'cdxgen' , '--yes' , command ] ,
87
+ spawnOpts
104
88
)
105
- } )
89
+ // @ts -ignore -- toHaveStderrInclude is defined above
90
+ ) . rejects . toHaveStderrInclude (
91
+ `${ LOG_SYMBOLS . fail } Unknown argument: ${ command } `
92
+ )
93
+ } )
106
94
107
- it ( 'should not forward multiple unknown commands to cdxgen' , async ( ) => {
108
- await expect (
109
- ( ) =>
110
- spawn (
111
- // Lazily access constants.execPath.
112
- constants . execPath ,
113
- [ entryPath , 'cdxgen' , '-u' , '-h' , '--unknown' ] ,
114
- spawnOpts
115
- )
116
- // @ts -ignore -- toHaveStderrStartWith is defined above
117
- ) . rejects . toHaveStderrStartWith (
118
- `${ LOG_SYMBOLS . fail } Unknown arguments: -u, --unknown`
95
+ it ( 'should not forward multiple unknown commands to cdxgen' , async ( ) => {
96
+ await expect (
97
+ ( ) =>
98
+ spawn (
99
+ // Lazily access constants.execPath.
100
+ constants . execPath ,
101
+ [ entryPath , 'cdxgen' , '-y' , '-u' , '-h' , '--unknown' ] ,
102
+ spawnOpts
119
103
)
120
- } )
121
- }
122
- )
123
- }
124
- )
104
+ // @ts -ignore -- toHaveStderrInclude is defined above
105
+ ) . rejects . toHaveStderrInclude (
106
+ `${ LOG_SYMBOLS . fail } Unknown arguments: -u, --unknown`
107
+ )
108
+ } )
109
+ } )
110
+ } )
0 commit comments