An npm error occurred while running `npm run unit -- --coverage=false`, but running `node_modules/.bin/jest --config test/unit/jest.conf.js` was normal
See original GitHub issueAdd an assertion failure expect(false).toBe(true)
to test/unit/specs/HelloWorld.spec.js
import Vue from 'vue'
import HelloWorld from '@/components/HelloWorld'
describe('HelloWorld.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(HelloWorld)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.toEqual('Welcome to Your Vue.js App')
expect(false).toBe(true) // for test
})
})
Run command
npm run unit -- --coverage=false
Output
> cp1@1.0.0 unit /xxx/cp1
> jest --config test/unit/jest.conf.js --coverage "--coverage=false"
FAIL test/unit/specs/HelloWorld.spec.js
HelloWorld.vue
✕ should render correct contents (29ms)
● HelloWorld.vue › should render correct contents
expect(received).toBe(expected)
Expected value to be (using ===):
true
Received:
false
at Object.<anonymous> (test/unit/specs/HelloWorld.spec.js:10:19)
at new Promise (<anonymous>)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.118s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cp1@1.0.0 unit: `jest --config test/unit/jest.conf.js --coverage "--coverage=false"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cp1@1.0.0 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! /Users/xxx/.npm/_logs/2018-01-11T08_09_15_737Z-debug.log
Run command
node_modules/.bin/jest --config test/unit/jest.conf.js
Output
➜ cp1 node_modules/.bin/jest --config test/unit/jest.conf.js
FAIL test/unit/specs/HelloWorld.spec.js
HelloWorld.vue
✕ should render correct contents (26ms)
● HelloWorld.vue › should render correct contents
expect(received).toBe(expected)
Expected value to be (using ===):
true
Received:
false
at Object.<anonymous> (test/unit/specs/HelloWorld.spec.js:10:19)
at new Promise (<anonymous>)
at <anonymous>
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.092s
Ran all test suites.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to fix npm throwing error without sudo - node.js
This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute: sudo chown -R $(whoami) ~/.npm....
Read more >Common errors | npm Docs
You are trying to install on a drive that either has no space, or has no permission to write. Free some disk space...
Read more >Configuring code coverage in Jest, the right way
In this brief tutorial we see how to configure code coverage for Jest ... By running npm test with this configuration in place...
Read more >How to NPM Start for React Tutorial Project | Pluralsight
It can help in setting up a new React project within minutes. This tool wraps up all the common dependencies so that a...
Read more >Missing package running jest - Running Tests - CircleCI Discuss
I have output node-modules folder content, and jest is there, still, the unit tests step fails due to a missing package error …...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ruanjf
npm run unit --silent
works just as well, any reason for specifying the coverage?found the following neat trick for test scripts here:
@therightstuff you suggestion actually fix the problem I encounter