@@ -254,3 +254,53 @@ test('should not allow users to sneak in a flag', async () => {
254
254
strictEqual ( result . stdout , '' ) ;
255
255
strictEqual ( result . code , 9 ) ;
256
256
} ) ;
257
+
258
+ test ( 'non object root' , async ( ) => {
259
+ const result = await spawnPromisified ( process . execPath , [
260
+ '--no-warnings' ,
261
+ '--experimental-config-file' ,
262
+ fixtures . path ( 'rc/non-object-root.json' ) ,
263
+ '-p' , '"Hello, World!"' ,
264
+ ] ) ;
265
+ match ( result . stderr , / R o o t v a l u e u n e x p e c t e d n o t a n o b j e c t f o r / ) ;
266
+ strictEqual ( result . stdout , '' ) ;
267
+ strictEqual ( result . code , 9 ) ;
268
+ } ) ;
269
+
270
+ test ( 'non object node options' , async ( ) => {
271
+ const result = await spawnPromisified ( process . execPath , [
272
+ '--no-warnings' ,
273
+ '--experimental-config-file' ,
274
+ fixtures . path ( 'rc/non-object-node-options.json' ) ,
275
+ '-p' , '"Hello, World!"' ,
276
+ ] ) ;
277
+ match ( result . stderr , / " n o d e O p t i o n s " v a l u e u n e x p e c t e d f o r / ) ;
278
+ strictEqual ( result . stdout , '' ) ;
279
+ strictEqual ( result . code , 9 ) ;
280
+ } ) ;
281
+
282
+ test ( 'should throw correct error when a json is broken' , async ( ) => {
283
+ const result = await spawnPromisified ( process . execPath , [
284
+ '--no-warnings' ,
285
+ '--experimental-config-file' ,
286
+ fixtures . path ( 'rc/broken.json' ) ,
287
+ '-p' , '"Hello, World!"' ,
288
+ ] ) ;
289
+ match ( result . stderr , / C a n ' t p a r s e / ) ;
290
+ match ( result . stderr , / b r o k e n \. j s o n : i n v a l i d c o n t e n t / ) ;
291
+ strictEqual ( result . stdout , '' ) ;
292
+ strictEqual ( result . code , 9 ) ;
293
+ } ) ;
294
+
295
+ test ( 'broken value in node_options' , async ( ) => {
296
+ const result = await spawnPromisified ( process . execPath , [
297
+ '--no-warnings' ,
298
+ '--experimental-config-file' ,
299
+ fixtures . path ( 'rc/broken-node-options.json' ) ,
300
+ '-p' , '"Hello, World!"' ,
301
+ ] ) ;
302
+ match ( result . stderr , / C a n ' t p a r s e / ) ;
303
+ match ( result . stderr , / b r o k e n - n o d e - o p t i o n s \. j s o n : i n v a l i d c o n t e n t / ) ;
304
+ strictEqual ( result . stdout , '' ) ;
305
+ strictEqual ( result . code , 9 ) ;
306
+ } ) ;
0 commit comments