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:
authorGar <gar+gh@danger.computer>2021-03-19 17:33:40 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-19 18:36:06 +0300
commite94a45851dcfa08d5ce92b6f17cd868acae94ee4 (patch)
treebd2aa35afa648119478d74b25c0ea8a8cd41e991 /test
parentd98edd124a61d2331f45599ba6f6dfc42f07cbce (diff)
fix(suggestions): clarify Unknown command output
Base commands and `npm run` need different outputs PR-URL: https://github.com/npm/cli/pull/2906 Credit: @wraithgar Close: #2906 Reviewed-by: @ruyadorno
Diffstat (limited to 'test')
-rw-r--r--test/lib/cli.js4
-rw-r--r--test/lib/run-script.js22
-rw-r--r--test/lib/utils/did-you-mean.js6
3 files changed, 14 insertions, 18 deletions
diff --git a/test/lib/cli.js b/test/lib/cli.js
index 59769e13f..40da77bf4 100644
--- a/test/lib/cli.js
+++ b/test/lib/cli.js
@@ -46,7 +46,7 @@ const npmlogMock = {
const requireInject = require('require-inject')
const cli = requireInject.installGlobally('../../lib/cli.js', {
'../../lib/npm.js': npmock,
- '../../lib/utils/did-you-mean.js': () => 'test did you mean',
+ '../../lib/utils/did-you-mean.js': () => '\ntest did you mean',
'../../lib/utils/unsupported.js': unsupportedMock,
'../../lib/utils/error-handler.js': errorHandlerMock,
npmlog: npmlogMock,
@@ -160,7 +160,7 @@ t.test('print usage if non-command param provided', t => {
npmock.argv = ['asdf']
npmock.output = (msg) => {
if (msg) {
- t.match(msg, 'test did you mean', 'outputs did you mean')
+ t.match(msg, 'Unknown command: "asdf"\ntest did you mean', 'outputs did you mean')
t.end()
}
}
diff --git a/test/lib/run-script.js b/test/lib/run-script.js
index db1fc4b5c..265565705 100644
--- a/test/lib/run-script.js
+++ b/test/lib/run-script.js
@@ -290,7 +290,7 @@ t.test('try to run missing script', t => {
t.test('no suggestions', t => {
runScript.exec(['notevenclose'], er => {
t.match(er, {
- message: 'Unknown command: "notevenclose"',
+ message: 'Missing script: "notevenclose"',
})
t.end()
})
@@ -298,7 +298,7 @@ t.test('try to run missing script', t => {
t.test('script suggestions', t => {
runScript.exec(['helo'], er => {
t.match(er, {
- message: 'Unknown command: "helo"',
+ message: 'Missing script: "helo"',
})
t.match(er, {
message: 'npm run hello',
@@ -309,7 +309,7 @@ t.test('try to run missing script', t => {
t.test('bin suggestions', t => {
runScript.exec(['goodneght'], er => {
t.match(er, {
- message: 'Unknown command: "goodneght"',
+ message: 'Missing script: "goodneght"',
})
t.match(er, {
message: 'npm exec goodnight',
@@ -896,27 +896,27 @@ t.test('workspaces', t => {
t.match(RUN_SCRIPTS, [])
t.strictSame(LOG.map(cleanOutput), [
'Lifecycle script `missing-script` failed with error:',
- 'Error: Unknown command: "missing-script"',
+ 'Error: Missing script: "missing-script"',
' in workspace: a@1.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/a',
'Lifecycle script `missing-script` failed with error:',
- 'Error: Unknown command: "missing-script"',
+ 'Error: Missing script: "missing-script"',
' in workspace: b@2.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/b',
'Lifecycle script `missing-script` failed with error:',
- 'Error: Unknown command: "missing-script"',
+ 'Error: Missing script: "missing-script"',
' in workspace: c@1.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/c',
'Lifecycle script `missing-script` failed with error:',
- 'Error: Unknown command: "missing-script"',
+ 'Error: Missing script: "missing-script"',
' in workspace: d@1.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/d',
'Lifecycle script `missing-script` failed with error:',
- 'Error: Unknown command: "missing-script"',
+ 'Error: Missing script: "missing-script"',
' in workspace: e',
' at location: {CWD}/test/lib/run-script-workspaces/packages/e',
'Lifecycle script `missing-script` failed with error:',
- 'Error: Unknown command: "missing-script"',
+ 'Error: Missing script: "missing-script"',
' in workspace: noscripts@1.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/noscripts',
], 'should log error msgs for each workspace script')
@@ -937,11 +937,11 @@ t.test('workspaces', t => {
t.match(RUN_SCRIPTS, [])
t.strictSame(LOG.map(cleanOutput), [
'Lifecycle script `test` failed with error:',
- 'Error: Unknown command: "test"',
+ 'Error: Missing script: "test"',
' in workspace: a@1.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/a',
'Lifecycle script `test` failed with error:',
- 'Error: Unknown command: "test"',
+ 'Error: Missing script: "test"',
' in workspace: b@2.0.0',
' at location: {CWD}/test/lib/run-script-workspaces/packages/b',
], 'should log error msgs for each workspace script')
diff --git a/test/lib/utils/did-you-mean.js b/test/lib/utils/did-you-mean.js
index 898806aa1..68893a800 100644
--- a/test/lib/utils/did-you-mean.js
+++ b/test/lib/utils/did-you-mean.js
@@ -8,23 +8,20 @@ t.test('did-you-mean', t => {
t.notOk(err)
t.test('nistall', async t => {
const result = await dym(npm, npm.localPrefix, 'nistall')
- t.match(result, 'Unknown command')
t.match(result, 'npm install')
})
t.test('sttest', async t => {
const result = await dym(npm, npm.localPrefix, 'sttest')
- t.match(result, 'Unknown command')
t.match(result, 'npm test')
t.match(result, 'npm run posttest')
})
t.test('npz', async t => {
const result = await dym(npm, npm.localPrefix, 'npxx')
- t.match(result, 'Unknown command')
t.match(result, 'npm exec npx')
})
t.test('qwuijbo', async t => {
const result = await dym(npm, npm.localPrefix, 'qwuijbo')
- t.match(result, 'Unknown command')
+ t.match(result, '')
})
t.end()
})
@@ -38,6 +35,5 @@ t.test('missing bin and script properties', async t => {
})
const result = await dym(npm, path, 'nistall')
- t.match(result, 'Unknown command')
t.match(result, 'npm install')
})