@@ -68,12 +68,15 @@ describe("vars", () => {
68
68
) ;
69
69
70
70
expect ( ctx . varsManager . get ( "newKey" ) ) . equals ( "newVal" ) ;
71
- assert (
72
- spyConsoleWarn . calledWith (
73
- `The configuration variable has been stored in ${ TMP_FILE_PATH } `
74
- )
75
- ) ;
76
71
expect ( code ) . equals ( 0 ) ;
72
+
73
+ if ( process . stdout . isTTY ) {
74
+ assert (
75
+ spyConsoleWarn . calledWith (
76
+ `The configuration variable has been stored in ${ TMP_FILE_PATH } `
77
+ )
78
+ ) ;
79
+ }
77
80
} ) ;
78
81
79
82
describe ( "cli user prompt" , ( ) => {
@@ -97,12 +100,15 @@ describe("vars", () => {
97
100
const code = await handleVars ( [ "vars" , "set" , "newKey" ] , undefined ) ;
98
101
99
102
expect ( ctx . varsManager . get ( "newKey" ) ) . equals ( "valueFromCli" ) ;
100
- assert (
101
- spyConsoleWarn . calledWith (
102
- `The configuration variable has been stored in ${ TMP_FILE_PATH } `
103
- )
104
- ) ;
105
103
expect ( code ) . equals ( 0 ) ;
104
+
105
+ if ( process . stdout . isTTY ) {
106
+ assert (
107
+ spyConsoleWarn . calledWith (
108
+ `The configuration variable has been stored in ${ TMP_FILE_PATH } `
109
+ )
110
+ ) ;
111
+ }
106
112
} ) ;
107
113
108
114
it ( "should throw an error because the cli user prompt for the value is not valid" , async ( ) => {
@@ -162,12 +168,16 @@ describe("vars", () => {
162
168
assert ( spyConsoleLog . getCall ( 2 ) . calledWith ( "key3" ) ) ;
163
169
assert ( spyConsoleLog . getCall ( 3 ) . calledWith ( "key4" ) ) ;
164
170
assert ( spyConsoleLog . getCall ( 4 ) . calledWith ( "key5" ) ) ;
165
- assert (
166
- spyConsoleWarn . calledWith (
167
- `\nAll configuration variables are stored in ${ TMP_FILE_PATH } `
168
- )
169
- ) ;
171
+
170
172
expect ( code ) . equals ( 0 ) ;
173
+
174
+ if ( process . stdout . isTTY ) {
175
+ assert (
176
+ spyConsoleWarn . calledWith (
177
+ `\nAll configuration variables are stored in ${ TMP_FILE_PATH } `
178
+ )
179
+ ) ;
180
+ }
171
181
} ) ;
172
182
173
183
it ( "should not list any key because they are not defined" , async ( ) => {
@@ -179,27 +189,35 @@ describe("vars", () => {
179
189
180
190
const code = await handleVars ( [ "vars" , "list" ] , undefined ) ;
181
191
182
- assert (
183
- spyConsoleWarn . calledWith (
184
- chalk . yellow (
185
- `There are no configuration variables stored in ${ TMP_FILE_PATH } `
186
- )
187
- )
188
- ) ;
189
192
expect ( code ) . equals ( 0 ) ;
193
+
194
+ if ( process . stdout . isTTY ) {
195
+ assert (
196
+ spyConsoleWarn . calledWith (
197
+ chalk . yellow (
198
+ `There are no configuration variables stored in ${ TMP_FILE_PATH } `
199
+ )
200
+ )
201
+ ) ;
202
+ }
190
203
} ) ;
191
204
} ) ;
192
205
193
206
describe ( "delete" , ( ) => {
194
207
it ( "should successfully delete a key and its value" , async ( ) => {
195
208
const code = await handleVars ( [ "vars" , "delete" , "key1" ] , undefined ) ;
209
+
196
210
assert ( ctx . varsManager . get ( "key1" ) === undefined ) ;
197
- assert (
198
- spyConsoleWarn . calledWith (
199
- `The configuration variable was deleted from ${ TMP_FILE_PATH } `
200
- )
201
- ) ;
211
+
202
212
expect ( code ) . equals ( 0 ) ;
213
+
214
+ if ( process . stdout . isTTY ) {
215
+ assert (
216
+ spyConsoleWarn . calledWith (
217
+ `The configuration variable was deleted from ${ TMP_FILE_PATH } `
218
+ )
219
+ ) ;
220
+ }
203
221
} ) ;
204
222
205
223
it ( "should show a warning because the key to delete cannot be found" , async ( ) => {
0 commit comments