npm test always fails

Steven Vachon's Avatar

Steven Vachon

20 Nov, 2014 03:59 AM

My tests pass locally on Windows with both cmd.exe and PowerShell. npm install always passes and npm test always fails. The error is always vague. I tried updating npm to latest with no change in result.

Here is my build config: https://github.com/stevenvachon/nopter/blob/master/appveyor.yml

If I run PowerShell first, it gives:

npm :   1 failing
At line:1 char:1
+ npm test # PowerShell
+ ~~~~~~~~
    + CategoryInfo          : NotSpecified: (  1 failing:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError


npm ERR! Test failed. See above for more details.


Command executed with exception: npm ERR! Test failed. See above for more details.

If I run cmd.exe first, it gives:

npm ERR! Test failed.  See above for more details.

Here is the latest build: https://ci.appveyor.com/project/stevenvachon/nopter

Please help.

  1. Support Staff 1 Posted by Feodor Fitsner on 20 Nov, 2014 04:14 AM

    Feodor Fitsner's Avatar

    PowerShell fails with NativeCommandError when a process writes to StdErr. Caused by this line: https://github.com/stevenvachon/nopter/blob/master/appveyor.yml#L37

  2. 2 Posted by Steven Vachon on 20 Nov, 2014 03:45 PM

    Steven Vachon's Avatar

    But if I comment out that line and let the next line run, it also fails. What is causing stderr? I don't see any stderr locally.

  3. Support Staff 3 Posted by Feodor Fitsner on 20 Nov, 2014 06:05 PM

    Feodor Fitsner's Avatar

    Is there any way to enable "diagnostics" mode in npm to see what's going?
    Have you tried running mocha without npm?

  4. 4 Posted by Steven Vachon on 20 Nov, 2014 06:31 PM

    Steven Vachon's Avatar

    Don't think npm has a diagnostics/debug mode.

    Running mocha this way has worked in the past https://ci.appveyor.com/project/stevenvachon/nopter/build/17 though sometimes it would magically fail like now, only to pass on an unchanged rebuild. Only difference is that now it never ceases to fail.

    Running mocha without npm would require a separate file that would use mocha's programmatic API instead of its CLI. However, switching out the mocha line for a basic node eval does work without failing: https://ci.appveyor.com/project/stevenvachon/nopter/build/36/job/kf...

    Could the issue be in how Appveyor's VM installs Node?

  5. Support Staff 5 Posted by Feodor Fitsner on 20 Nov, 2014 06:40 PM

    Feodor Fitsner's Avatar

    Hm, maybe it's the new way AV switches node.js versions. That build #17 was working month ago before you changed the way of switching Node version: https://github.com/stevenvachon/nopter/blob/18725b3831023e0cab50c3e...

    Try that method again to see if that helps.

  6. 6 Posted by Steven Vachon on 20 Nov, 2014 06:52 PM

    Steven Vachon's Avatar

    Yeah, it was failing with that method as well which led me to discovering the new method which, while performing faster, did not fix the current situation.

    I just ran another test which uses mocha's CLI in npm, but I only run the help command: https://ci.appveyor.com/project/stevenvachon/nopter/build/37/job/qo... It passes. So the issue must be in the tests somewhere or in mocha's code.

  7. 7 Posted by Steven Vachon on 20 Nov, 2014 07:04 PM

    Steven Vachon's Avatar

    Running a simple test of mocha's API passes: https://ci.appveyor.com/project/stevenvachon/nopter/build/38/job/18... So the issue must not be mocha.

  8. 8 Posted by Steven Vachon on 20 Nov, 2014 09:55 PM

    Steven Vachon's Avatar

    AppVeyor is not showing stdout from mocha or any of my code. Is there a reason or this? It's making debugging this very time consuming. https://ci.appveyor.com/project/stevenvachon/nopter/build/job/4k2ab...

  9. Support Staff 9 Posted by Feodor Fitsner on 20 Nov, 2014 10:19 PM

    Feodor Fitsner's Avatar

    That's strange because it collects both StdOut and StdErr. Haven't had such issues with other tools. Is it mocha specific?

  10. 10 Posted by Steven Vachon on 20 Nov, 2014 10:49 PM

    Steven Vachon's Avatar

    Seems to be a Node issue that many projects including Grunt have had monkey patched for years but Mocha has not.

    https://github.com/mochajs/mocha/issues/333
    https://github.com/joyent/node/issues/3584

    I'm able to get stdout when no tests fail (which call process.exit()).

    This solves the issue. Thank you for your efforts!

  11. Support Staff 11 Posted by Feodor Fitsner on 20 Nov, 2014 10:53 PM

    Feodor Fitsner's Avatar

    Oh, cool. So, what was a fix - updating mocha?

  12. 12 Posted by Steven Vachon on 20 Nov, 2014 10:58 PM

    Steven Vachon's Avatar

    Actually, wait, I'd forgotten that I'd ran my last test without Mocha. Even with all tests passing in Mocha, it isn't logging anything. The really confusing part is that my other projects log everything. It's probably something stupid.

    Currently there is no fix. I'll have to keep plugging at it.

  13. 13 Posted by Steven Vachon on 21 Nov, 2014 01:00 AM

    Steven Vachon's Avatar

    Ok, I think that I have it sorted out now. What I'd said before was true -- process.exit() is the culprit. I was having further issues by using a special mocha function (only()) which was calling process.exit() even when the test(s) passed.

    It does not appear that mocha has addressed this issue directly. However, using its --no-exit CLI option avoids the issue and displays the log as expected for both passed and failed test suites.

  14. Support Staff 14 Posted by Feodor Fitsner on 21 Nov, 2014 01:29 AM

    Feodor Fitsner's Avatar

    Great, thanks for the update! This is definitely helpful for others setting up mocha tests.

  15. Steven Vachon closed this discussion on 21 Nov, 2014 01:45 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

21 Aug, 2019 11:06 PM
21 Aug, 2019 02:08 PM
21 Aug, 2019 01:37 PM
21 Aug, 2019 10:21 AM
21 Aug, 2019 09:10 AM

 

21 Aug, 2019 05:56 AM
21 Aug, 2019 03:08 AM
20 Aug, 2019 11:33 PM
20 Aug, 2019 08:07 PM
20 Aug, 2019 05:50 PM
20 Aug, 2019 12:35 PM