Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm throws errors when tests fail #1449

Closed
rowild opened this issue Feb 24, 2020 · 7 comments
Closed

npm throws errors when tests fail #1449

rowild opened this issue Feb 24, 2020 · 7 comments

Comments

@rowild
Copy link

rowild commented Feb 24, 2020

Version

1.0.0-beta.31

Reproduction link

https://github.com/rowild/vue-unit-testing

Steps to reproduce

  1. clone the repo
  2. npm run test:unit

What is expected?

The console should report only the test results (some of which are currently failing).

What is actually happening?

Additionally to the test results npm throws errors.


I read somewhere that this problem also appears with mocha "which always exists with code !==0". It might be that this is also the case with jest:
jestjs/jest#5841
However, I don't know, how to deal with it. Maybe a note about this "phenomenon" could be added to the official docu? Thank you!

@lmiller1990
Copy link
Member

Can you please copy paste the error log here? This doesn't really sound like a VTU problem, but a test runner issue.

@rowild
Copy link
Author

rowild commented Feb 24, 2020

Here it is, hope it's readable:

> npm run test:unit                        

> [email protected] test:unit /Volumes/_II_/_SITES/__TESTS/_TestsWithVueAndNuxt/vue-unit-testing
> vue-cli-service test:unit

 FAIL  tests/unit/RandomNumber.spec.js
  ● RandomNumber.vue › By default randomNumber dat value is 0

    expect(received).toBe(expected) // Object.is equality

    Expected: false
    Received: true

       8 |   test('By default randomNumber dat value is 0', () => {
       9 |     // expect(wrapper.html()).toContain('<span>0</span>')
    > 10 |     expect(true).toBe(false)
         |                  ^
      11 |   })
      12 | 
      13 |   // it's also easy to check for the existence of elements

      at Object.<anonymous> (tests/unit/RandomNumber.spec.js:10:18)

  ● RandomNumber.vue › If the generateRandomNumber button is clicked, the value of randomNuber is between 1 and 10

    expect(received).toBe(expected) // Object.is equality

    Expected: false
    Received: true

      22 |     // expect(randomNumber).toBeGreaterThanOrEqual(1)
      23 |     // expect(randomNumber).toBeLessThanOrEqual(10)
    > 24 |     expect(true).toBe(false)
         |                  ^
      25 |   })
      26 | 
      27 |   test('If the generateRandomNumber button is clicked, the value of randomNuber is between 200 and 300 (testing proper usage of props)', async () => {

      at Object.<anonymous> (tests/unit/RandomNumber.spec.js:24:18)

  ● RandomNumber.vue › If the generateRandomNumber button is clicked, the value of randomNuber is between 200 and 300 (testing proper usage of props)

    expect(received).toBe(expected) // Object.is equality

    Expected: false
    Received: true

      33 |     // expect(randomNumber).toBeLessThanOrEqual(300)
      34 | 
    > 35 |     expect(true).toBe(false)
         |                  ^
      36 |   })
      37 | })
      38 | 

      at Object.<anonymous> (tests/unit/RandomNumber.spec.js:35:18)

 PASS  tests/unit/AppHeader.spec.js

Test Suites: 1 failed, 1 passed, 2 total
Tests:       3 failed, 2 passed, 5 total
Snapshots:   0 total
Time:        1.029s
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!     /Users/rowild/.npm/_logs/2020-02-24T12_31_06_629Z-debug.log

And the error log's content:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'test:unit' ]
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: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Volumes/_II_/_SITES/__TESTS/_TestsWithVueAndNuxt/vue-unit-testing/node_modules/.bin:/Users/rowild/.pyenv/shims:/Users/rowild/.pyenv/bin:/Users/rowild/.pub-cache/bin:/Users/rowild/flutter/bin:/Users/rowild/.jenv/shims:/Users/rowild/.jenv/bin:/Users/rowild/.composer/vendor/bin:/usr/local/opt/[email protected]/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/rowild/.pyenv/shims:/Users/rowild/.pyenv/bin:/Users/rowild/.pub-cache/bin:/Users/rowild/flutter/bin:/Users/rowild/.jenv/shims:/Users/rowild/.jenv/bin:/Users/rowild/.composer/vendor/bin:/usr/local/opt/[email protected]/bin:/usr/local/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
9 verbose lifecycle [email protected]~test:unit: CWD: /Volumes/_II_/_SITES/__TESTS/_TestsWithVueAndNuxt/vue-unit-testing
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> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:311:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:311:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd /Volumes/_II_/_SITES/__TESTS/_TestsWithVueAndNuxt/vue-unit-testing
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:unit"
18 verbose node v12.16.1
19 verbose npm  v6.13.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 ]

@lmiller1990
Copy link
Member

lmiller1990 commented Feb 25, 2020

I checked this out and it all works fine for me -- all the test pass. It looks like a problem with your set up... maybe try a different version of node? Uninstall/reinstall? 🤔

I'm going to close this since I don't think this is a bug in VTU. I can try and give you some more ideas to debugging it if reinstalling node doesn't work for you. Does this happen to you on other repositories using Vue Test Utils?

@rowild
Copy link
Author

rowild commented Feb 25, 2020

Thank you, @lmiller1990 , for your feedback and checking the problem! It is good to know that it happens to my nodejs setup only.

I of course went through the uninstall/re-install procedure before I posted here, but it seems that I missed some spots to clear out completely.

Currently, this happens on all repos with tests that I use (well... I only have two...).

I will report back, when I have more useable information. Thanks again!

@lmiller1990
Copy link
Member

If it happens on all repos, it's a sign its your environment. Try reinstalling node.js, and we can go from there.

@ghost
Copy link

ghost commented Apr 11, 2020

I faced the same issue. It turns out that this is the expected behaviour of Jest

@tacvbo89
Copy link

imagen
Hi, I have been the same problem, i solved with node version manager, just I changed the version of node, it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants