Reputation: 91
I'm trying to run npm run test:unit
and the true error seems to be test:unit: Failed to exec test:unit script
from the npm debug.log. Yet the script DOES run and execute without issue.
I'm a little new to NPM + Node so I'm struggling with this behavior. When I run npm run test:unit
( "test:unit": "vue-cli-service test:unit"
in Package.json) I get this output:
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 file obsolete, 0 total
Time: 1.208s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:unit: `vue-cli-service test:unit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/max/.npm/_logs/2020-03-26T18_16_36_155Z-debug.log
Expected Result The tests should just pass, I shouldn't see NPM/Node crash.
Running ./node_modules/.bin/vue-cli-service test:unit
I get just the test and Jest output. Everything works as expected. So what is going wrong with my setup?
Attempted Resolution
npm_debug.log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/max/.nvm/versions/node/v13.11.0/bin/node',
1 verbose cli '/home/max/.nvm/versions/node/v13.11.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test:unit'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest:unit', 'test:unit', 'posttest:unit' ]
5 info lifecycle [email protected]~pretest:unit: [email protected]
6 info lifecycle [email protected]~test:unit: [email protected]
7 verbose lifecycle [email protected]~test:unit: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~test:unit: PATH: /home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/max/cheatsheet_project/cheatsheet/node_modules/.bin:/home/max/.pyenv/plugins/pyenv-virtualenv/shims:/home/max/.pyenv/shims:~/.pyenv/bin:/home/max/Maven/apache-maven-3.5.2/bin:/home/max/.nvm/versions/node/v13.11.0/bin:/home/max/.rbenv/shims:/home/max/.rbenv/bin:/home/max/workspace/go/bin:/home/max/.cargo/bin:/home/max/.cargo/bin:/home/max/bin:/home/max/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/usr/local/go/bin
9 verbose lifecycle [email protected]~test:unit: CWD: /home/max/cheatsheet_project/cheatsheet
10 silly lifecycle [email protected]~test:unit: Args: [ '-c', 'vue-cli-service test:unit' ]
11 silly lifecycle [email protected]~test:unit: Returned: code: 1 signal: null
12 info lifecycle [email protected]~test:unit: Failed to exec test:unit script
13 verbose stack Error: [email protected] test:unit: `vue-cli-service test:unit`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1026:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/max/cheatsheet_project/cheatsheet
16 verbose Linux 4.15.0-91-generic
17 verbose argv "/home/max/.nvm/versions/node/v13.11.0/bin/node" "/home/max/.nvm/versions/node/v13.11.0/bin/npm" "run" "test:unit"
18 verbose node v13.11.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] test:unit: `vue-cli-service test:unit`
22 error Exit status 1
23 error Failed at the [email protected] test:unit script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Upvotes: 1
Views: 2718
Reputation: 91
./node_modules/.bin/vue-cli-service test:unit -u
fixed this. This is the shorthand command for jest --updatesnapshot
.
Since we just updated our component to point to a different address, it's reasonable to expect changes in the snapshot for this component. Our snapshot test case is failing because the snapshot for our updated component no longer matches the snapshot artifact for this test case.
To resolve this, we will need to update our snapshot artifacts. You can run Jest with a flag that will tell it to re-generate snapshots... - From Snapshot Testing.
Observed the error about snapshots:
Snapshots: 1 file obsolete, 0 total
Unsure why this caused the NPM error but -u
cleared it and I haven't seen it again.
Upvotes: 1