Skip to content

Commit 1f3ab84

Browse files
ryaninventsgr2m
authored andcommitted
test: add test coverage for config resolution
1 parent 1395b18 commit 1f3ab84

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/set-npmrc-auth.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ test('Throw error if "NPM_TOKEN" is missing', async t => {
7070
t.is(error.code, 'ENONPMTOKEN');
7171
});
7272

73+
test('Emulate npm config resolution if "NPM_CONFIG_USERCONFIG" is set', async t => {
74+
const cwd = tempy.directory();
75+
76+
await appendFile(path.resolve(cwd, '.custom-npmrc'), `//custom.registry.com/:_authToken = \${NPM_TOKEN}`);
77+
78+
await setNpmrcAuth('http://custom.registry.com', {
79+
cwd,
80+
env: {NPM_CONFIG_USERCONFIG: path.resolve(cwd, '.custom-npmrc')},
81+
logger: t.context.logger,
82+
});
83+
84+
t.is(t.context.log.callCount, 1);
85+
});
86+
7387
test('Throw error if "NPM_USERNAME" is missing', async t => {
7488
const cwd = tempy.directory();
7589
const env = {NPM_PASSWORD: 'npm_pasword', NPM_EMAIL: 'npm_email'};

0 commit comments

Comments
 (0)