@@ -26,6 +26,7 @@ test.beforeEach(async t => {
2626 delete process . env . NPM_USERNAME ;
2727 delete process . env . NPM_PASSWORD ;
2828 delete process . env . NPM_EMAIL ;
29+ delete process . env . DEFAULT_NPM_REGISTRY ;
2930 // Create a git repository, set the current working directory at the root of the repo
3031 await gitRepo ( ) ;
3132 await gitCommit ( 'Initial commit' ) ;
@@ -58,6 +59,7 @@ test.serial('Skip npm auth verification if "npmPublish" is false', async t => {
5859
5960test . serial ( 'Throws error if NPM token is invalid' , async t => {
6061 process . env . NPM_TOKEN = 'wrong_token' ;
62+ process . env . DEFAULT_NPM_REGISTRY = npmRegistry . url ;
6163 const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
6264 await outputJson ( './package.json' , pkg ) ;
6365 const error = await t . throws ( t . context . m . verifyConditions ( { } , { options : { } , logger : t . context . logger } ) ) ;
@@ -70,10 +72,21 @@ test.serial('Throws error if NPM token is invalid', async t => {
7072 t . regex ( npmrc , / : _ a u t h T o k e n / ) ;
7173} ) ;
7274
75+ test . serial ( 'Skip Token validation if the registry configured is not the default one' , async t => {
76+ process . env . NPM_TOKEN = 'wrong_token' ;
77+ const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : 'http://custom-registry.com/' } } ;
78+ await outputJson ( './package.json' , pkg ) ;
79+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options : { } , logger : t . context . logger } ) ) ;
80+
81+ const npmrc = ( await readFile ( '.npmrc' ) ) . toString ( ) ;
82+ t . regex ( npmrc , / : _ a u t h T o k e n / ) ;
83+ } ) ;
84+
7385test . serial (
7486 'Throws error if NPM token is invalid if "npmPublish" is false and npm plugin used for "getLastRelease"' ,
7587 async t => {
7688 process . env . NPM_TOKEN = 'wrong_token' ;
89+ process . env . DEFAULT_NPM_REGISTRY = npmRegistry . url ;
7790 const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
7891 await outputJson ( './package.json' , pkg ) ;
7992 const error = await t . throws (
@@ -96,6 +109,7 @@ test.serial(
96109 'Throws error if NPM token is invalid if "npmPublish" is false and npm plugin used for "getLastRelease" as an object' ,
97110 async t => {
98111 process . env . NPM_TOKEN = 'wrong_token' ;
112+ process . env . DEFAULT_NPM_REGISTRY = npmRegistry . url ;
99113 const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
100114 await outputJson ( './package.json' , pkg ) ;
101115 const error = await t . throws (
0 commit comments