@@ -341,8 +341,10 @@ t.test('can publish a tarball', async t => {
341341
342342t . test ( 'should check auth for default registry' , async t => {
343343 t . plan ( 2 )
344- const Publish = t . mock ( '../../../lib/commands/publish.js' )
345344 const npm = mockNpm ( )
345+ const registry = npm . config . get ( 'registry' )
346+ const errorMessage = `This command requires you to be logged in to ${ registry } `
347+ const Publish = t . mock ( '../../../lib/commands/publish.js' )
346348 npm . config . getCredentialsByURI = uri => {
347349 t . same ( uri , npm . config . get ( 'registry' ) , 'gets credentials for expected registry' )
348350 return { }
@@ -351,14 +353,15 @@ t.test('should check auth for default registry', async t => {
351353
352354 await t . rejects (
353355 publish . exec ( [ ] ) ,
354- { message : 'This command requires you to be logged in.' , code : 'ENEEDAUTH' } ,
356+ { message : errorMessage , code : 'ENEEDAUTH' } ,
355357 'throws when not logged in'
356358 )
357359} )
358360
359361t . test ( 'should check auth for configured registry' , async t => {
360362 t . plan ( 2 )
361363 const registry = 'https://some.registry'
364+ const errorMessage = 'This command requires you to be logged in to https://some.registry'
362365 const Publish = t . mock ( '../../../lib/commands/publish.js' )
363366 const npm = mockNpm ( {
364367 flatOptions : { registry } ,
@@ -371,14 +374,15 @@ t.test('should check auth for configured registry', async t => {
371374
372375 await t . rejects (
373376 publish . exec ( [ ] ) ,
374- { message : 'This command requires you to be logged in.' , code : 'ENEEDAUTH' } ,
377+ { message : errorMessage , code : 'ENEEDAUTH' } ,
375378 'throws when not logged in'
376379 )
377380} )
378381
379382t . test ( 'should check auth for scope specific registry' , async t => {
380383 t . plan ( 2 )
381384 const registry = 'https://some.registry'
385+ const errorMessage = 'This command requires you to be logged in to https://some.registry'
382386 const testDir = t . testdir ( {
383387 'package.json' : JSON . stringify (
384388 {
@@ -402,7 +406,7 @@ t.test('should check auth for scope specific registry', async t => {
402406
403407 await t . rejects (
404408 publish . exec ( [ testDir ] ) ,
405- { message : 'This command requires you to be logged in.' , code : 'ENEEDAUTH' } ,
409+ { message : errorMessage , code : 'ENEEDAUTH' } ,
406410 'throws when not logged in'
407411 )
408412} )
@@ -735,7 +739,7 @@ t.test('private workspaces', async t => {
735739 } )
736740
737741 t . test ( 'unexpected error' , async t => {
738- t . plan ( 1 )
742+ t . plan ( 2 )
739743
740744 const Publish = t . mock ( '../../../lib/commands/publish.js' , {
741745 ...mocks ,
@@ -749,7 +753,9 @@ t.test('private workspaces', async t => {
749753 } ,
750754 } ,
751755 'proc-log' : {
752- notice ( ) { } ,
756+ notice ( __ , msg ) {
757+ t . match ( msg , 'Publishing to https://registry.npmjs.org/' )
758+ } ,
753759 verbose ( ) { } ,
754760 } ,
755761 } )
0 commit comments