@@ -237,9 +237,10 @@ loglevel = yolo
237237 } )
238238 logs . length = 0
239239 await config . load ( )
240- t . match ( logs , [ [ 'verbose' , 'config' , 'error loading user config' , {
241- message : 'weird error' ,
242- } ] ] )
240+ t . match ( logs . find ( l => l [ 0 ] === 'verbose' ) ,
241+ [ 'verbose' , 'config' , 'error loading user config' , {
242+ message : 'weird error' ,
243+ } ] )
243244 logs . length = 0
244245 } )
245246
@@ -375,7 +376,7 @@ loglevel = yolo
375376
376377 // warn logs are emitted as a side effect of validate
377378 config . validate ( )
378- t . strictSame ( logs , [
379+ t . strictSame ( logs . filter ( l => l [ 0 ] === 'warn' ) , [
379380 [ 'warn' , 'invalid config' , 'registry="hello"' , 'set in command line options' ] ,
380381 [ 'warn' , 'invalid config' , 'Must be' , 'full url with "http://"' ] ,
381382 [ 'warn' , 'invalid config' , 'proxy="hello"' , 'set in command line options' ] ,
@@ -392,8 +393,7 @@ loglevel = yolo
392393 [ 'warn' , 'invalid config' , 'prefix=true' , 'set in command line options' ] ,
393394 [ 'warn' , 'invalid config' , 'Must be' , 'valid filesystem path' ] ,
394395 [ 'warn' , 'config' , 'also' , 'Please use --include=dev instead.' ] ,
395- [ 'warn' , 'invalid config' , 'loglevel="yolo"' ,
396- `set in ${ resolve ( path , 'project/.npmrc' ) } ` ] ,
396+ [ 'warn' , 'invalid config' , 'loglevel="yolo"' , `set in ${ resolve ( path , 'project/.npmrc' ) } ` ] ,
397397 [ 'warn' , 'invalid config' , 'Must be one of:' ,
398398 [ 'silent' , 'error' , 'warn' , 'notice' , 'http' , 'info' , 'verbose' , 'silly' ] . join ( ', ' ) ,
399399 ] ,
@@ -570,7 +570,7 @@ loglevel = yolo
570570 all : config . get ( 'all' ) ,
571571 } )
572572
573- t . strictSame ( logs , [
573+ t . strictSame ( logs . filter ( l => l [ 0 ] === 'warn' ) , [
574574 [ 'warn' , 'invalid config' , 'registry="hello"' , 'set in command line options' ] ,
575575 [ 'warn' , 'invalid config' , 'Must be' , 'full url with "http://"' ] ,
576576 [ 'warn' , 'invalid config' , 'proxy="hello"' , 'set in command line options' ] ,
@@ -1183,8 +1183,9 @@ t.test('workspaces', async (t) => {
11831183 await config . load ( )
11841184 t . equal ( config . localPrefix , path , 'localPrefix is the root' )
11851185 t . same ( config . get ( 'workspace' ) , [ join ( path , 'workspaces' , 'one' ) ] , 'set the workspace' )
1186- t . equal ( logs . length , 1 , 'got one log message' )
1187- t . match ( logs [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1186+ const info = logs . filter ( l => l [ 0 ] === 'info' )
1187+ t . equal ( info . length , 1 , 'got one log message' )
1188+ t . match ( info [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
11881189 } )
11891190
11901191 t . test ( 'finds other workspace parent' , async ( t ) => {
@@ -1204,8 +1205,9 @@ t.test('workspaces', async (t) => {
12041205 await config . load ( )
12051206 t . equal ( config . localPrefix , path , 'localPrefix is the root' )
12061207 t . same ( config . get ( 'workspace' ) , [ '../two' ] , 'kept the specified workspace' )
1207- t . equal ( logs . length , 1 , 'got one log message' )
1208- t . match ( logs [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1208+ const info = logs . filter ( l => l [ 0 ] === 'info' )
1209+ t . equal ( info . length , 1 , 'got one log message' )
1210+ t . match ( info [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
12091211 } )
12101212
12111213 t . test ( 'warns when workspace has .npmrc' , async ( t ) => {
@@ -1225,9 +1227,10 @@ t.test('workspaces', async (t) => {
12251227 await config . load ( )
12261228 t . equal ( config . localPrefix , path , 'localPrefix is the root' )
12271229 t . same ( config . get ( 'workspace' ) , [ join ( path , 'workspaces' , 'three' ) ] , 'kept the workspace' )
1228- t . equal ( logs . length , 2 , 'got two log messages' )
1229- t . match ( logs [ 0 ] , [ 'warn' , / ^ i g n o r i n g w o r k s p a c e c o n f i g / ] , 'warned about ignored config' )
1230- t . match ( logs [ 1 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1230+ const filtered = logs . filter ( l => l [ 0 ] === 'info' || l [ 0 ] === 'warn' )
1231+ t . equal ( filtered . length , 2 , 'got two log messages' )
1232+ t . match ( filtered [ 0 ] , [ 'warn' , / ^ i g n o r i n g w o r k s p a c e c o n f i g / ] , 'warned about ignored config' )
1233+ t . match ( filtered [ 1 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
12311234 } )
12321235
12331236 t . test ( 'prefix skips auto detect' , async ( t ) => {
@@ -1247,7 +1250,8 @@ t.test('workspaces', async (t) => {
12471250 await config . load ( )
12481251 t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
12491252 t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1250- t . equal ( logs . length , 0 , 'got no log messages' )
1253+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1254+ t . equal ( filtered . length , 0 , 'got no log messages' )
12511255 } )
12521256
12531257 t . test ( 'no-workspaces skips auto detect' , async ( t ) => {
@@ -1267,7 +1271,8 @@ t.test('workspaces', async (t) => {
12671271 await config . load ( )
12681272 t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
12691273 t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1270- t . equal ( logs . length , 0 , 'got no log messages' )
1274+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1275+ t . equal ( filtered . length , 0 , 'got no log messages' )
12711276 } )
12721277
12731278 t . test ( 'global skips auto detect' , async ( t ) => {
@@ -1287,7 +1292,8 @@ t.test('workspaces', async (t) => {
12871292 await config . load ( )
12881293 t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
12891294 t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1290- t . equal ( logs . length , 0 , 'got no log messages' )
1295+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1296+ t . equal ( filtered . length , 0 , 'got no log messages' )
12911297 } )
12921298
12931299 t . test ( 'location=global skips auto detect' , async ( t ) => {
@@ -1307,7 +1313,8 @@ t.test('workspaces', async (t) => {
13071313 await config . load ( )
13081314 t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
13091315 t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1310- t . equal ( logs . length , 0 , 'got no log messages' )
1316+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1317+ t . equal ( filtered . length , 0 , 'got no log messages' )
13111318 } )
13121319
13131320 t . test ( 'excludeNpmCwd skips auto detect' , async ( t ) => {
@@ -1328,7 +1335,8 @@ t.test('workspaces', async (t) => {
13281335 await config . load ( )
13291336 t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
13301337 t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1331- t . equal ( logs . length , 0 , 'got no log messages' )
1338+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1339+ t . equal ( filtered . length , 0 , 'got no log messages' )
13321340 } )
13331341
13341342 t . test ( 'does not error for invalid package.json' , async ( t ) => {
@@ -1354,8 +1362,9 @@ t.test('workspaces', async (t) => {
13541362 await config . load ( )
13551363 t . equal ( config . localPrefix , path , 'localPrefix is the root' )
13561364 t . same ( config . get ( 'workspace' ) , [ join ( path , 'workspaces' , 'one' ) ] , 'set the workspace' )
1357- t . equal ( logs . length , 1 , 'got one log message' )
1358- t . match ( logs [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1365+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1366+ t . equal ( filtered . length , 1 , 'got one log message' )
1367+ t . match ( filtered [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
13591368 } )
13601369} )
13611370
@@ -1474,7 +1483,8 @@ t.test('catch project config prefix error', async t => {
14741483 logs . length = 0
14751484 // config.load() triggers the error to be logged
14761485 await config . load ( )
1477- t . match ( logs , [ [
1486+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1487+ t . match ( filtered , [ [
14781488 'error' , 'config' , `prefix cannot be changed from project config: ${ path } ` ,
14791489 ] ] , 'Expected error logged' )
14801490} )
0 commit comments