@@ -62,11 +62,25 @@ test('non-existent', createFixture, [{
6262 ) ;
6363} ) ;
6464
65- test ( 'error' , createFixture , [ {
65+ test ( 'error on default registry ' , createFixture , [ {
6666 command : accessCommand ( '@private/pkg' ) ,
6767 stderr : 'npm ERR! code E403\nnpm ERR! 403 403 Forbidden' ,
6868} ] , async ( { t, testedModule : { collaborators} } ) => {
6969 const { stderr} = await t . throwsAsync ( collaborators ( { name : '@private/pkg' } ) ) ;
7070 t . is ( stderr , 'npm ERR! code E403\nnpm ERR! 403 403 Forbidden' ) ;
7171} ) ;
7272
73+ test ( 'error on external registry - returns false' , createFixture , [ {
74+ command : `${ accessCommand ( '@private/pkg' ) } --registry http://my-internal-registry.local` ,
75+ stderr : 'npm ERR! code E403\nnpm ERR! 403 403 Forbidden' ,
76+ } ] , async ( { t, testedModule : { collaborators} } ) => {
77+ // Errors should return false instead of throwing, since external registries
78+ // often don't support the collaborators endpoint.
79+ // See: https://github.com/sindresorhus/np/issues/420
80+ t . is ( await collaborators ( {
81+ name : '@private/pkg' ,
82+ publishConfig : {
83+ registry : 'http://my-internal-registry.local' ,
84+ } ,
85+ } ) , false ) ;
86+ } ) ;
0 commit comments