Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2021-12-09 02:07:23 +0300
committernlf <quitlahok@gmail.com>2021-12-09 02:29:02 +0300
commit166d9e144b38087ee5e7d8aaf6ec7d602cf2957c (patch)
treee5f0f4991a4077355837a1b2ba991576aca6afc4 /test
parente605b128c87620aae843cdbd8f35cc614da3f8a2 (diff)
fix: output configured registry during publish
Closes: npm/statusboard#416 PR-URL: https://github.com/npm/cli/pull/4143 Credit: @lukekarrys Close: #4143 Reviewed-by: @wraithgar
Diffstat (limited to 'test')
-rw-r--r--test/lib/commands/publish.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js
index 1178cd6ee..2a591fd4c 100644
--- a/test/lib/commands/publish.js
+++ b/test/lib/commands/publish.js
@@ -341,8 +341,10 @@ t.test('can publish a tarball', async t => {
t.test('should check auth for default registry', async t => {
t.plan(2)
- const Publish = t.mock('../../../lib/commands/publish.js')
const npm = mockNpm()
+ const registry = npm.config.get('registry')
+ const errorMessage = `This command requires you to be logged in to ${registry}`
+ const Publish = t.mock('../../../lib/commands/publish.js')
npm.config.getCredentialsByURI = uri => {
t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry')
return {}
@@ -351,7 +353,7 @@ t.test('should check auth for default registry', async t => {
await t.rejects(
publish.exec([]),
- { message: 'This command requires you to be logged in.', code: 'ENEEDAUTH' },
+ { message: errorMessage, code: 'ENEEDAUTH' },
'throws when not logged in'
)
})
@@ -359,6 +361,7 @@ t.test('should check auth for default registry', async t => {
t.test('should check auth for configured registry', async t => {
t.plan(2)
const registry = 'https://some.registry'
+ const errorMessage = 'This command requires you to be logged in to https://some.registry'
const Publish = t.mock('../../../lib/commands/publish.js')
const npm = mockNpm({
flatOptions: { registry },
@@ -371,7 +374,7 @@ t.test('should check auth for configured registry', async t => {
await t.rejects(
publish.exec([]),
- { message: 'This command requires you to be logged in.', code: 'ENEEDAUTH' },
+ { message: errorMessage, code: 'ENEEDAUTH' },
'throws when not logged in'
)
})
@@ -379,6 +382,7 @@ t.test('should check auth for configured registry', async t => {
t.test('should check auth for scope specific registry', async t => {
t.plan(2)
const registry = 'https://some.registry'
+ const errorMessage = 'This command requires you to be logged in to https://some.registry'
const testDir = t.testdir({
'package.json': JSON.stringify(
{
@@ -402,7 +406,7 @@ t.test('should check auth for scope specific registry', async t => {
await t.rejects(
publish.exec([testDir]),
- { message: 'This command requires you to be logged in.', code: 'ENEEDAUTH' },
+ { message: errorMessage, code: 'ENEEDAUTH' },
'throws when not logged in'
)
})
@@ -735,7 +739,7 @@ t.test('private workspaces', async t => {
})
t.test('unexpected error', async t => {
- t.plan(1)
+ t.plan(2)
const Publish = t.mock('../../../lib/commands/publish.js', {
...mocks,
@@ -749,7 +753,9 @@ t.test('private workspaces', async t => {
},
},
'proc-log': {
- notice () {},
+ notice (__, msg) {
+ t.match(msg, 'Publishing to https://registry.npmjs.org/')
+ },
verbose () {},
},
})