npm test always fails
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.
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
Support Staff 1 Posted by Feodor Fitsner on 20 Nov, 2014 04:14 AM
PowerShell fails with
NativeCommandError
when a process writes to StdErr. Caused by this line: https://github.com/stevenvachon/nopter/blob/master/appveyor.yml#L372 Posted by Steven Vachon on 20 Nov, 2014 03:45 PM
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.
Support Staff 3 Posted by Feodor Fitsner on 20 Nov, 2014 06:05 PM
Is there any way to enable "diagnostics" mode in npm to see what's going?
Have you tried running mocha without npm?
4 Posted by Steven Vachon on 20 Nov, 2014 06:31 PM
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?
Support Staff 5 Posted by Feodor Fitsner on 20 Nov, 2014 06:40 PM
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 Posted by Steven Vachon on 20 Nov, 2014 06:52 PM
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 Posted by Steven Vachon on 20 Nov, 2014 07:04 PM
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 Posted by Steven Vachon on 20 Nov, 2014 09:55 PM
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...
Support Staff 9 Posted by Feodor Fitsner on 20 Nov, 2014 10:19 PM
That's strange because it collects both StdOut and StdErr. Haven't had such issues with other tools. Is it mocha specific?
10 Posted by Steven Vachon on 20 Nov, 2014 10:49 PM
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!
Support Staff 11 Posted by Feodor Fitsner on 20 Nov, 2014 10:53 PM
Oh, cool. So, what was a fix - updating mocha?
12 Posted by Steven Vachon on 20 Nov, 2014 10:58 PM
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 Posted by Steven Vachon on 21 Nov, 2014 01:00 AM
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 callingprocess.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.Support Staff 14 Posted by Feodor Fitsner on 21 Nov, 2014 01:29 AM
Great, thanks for the update! This is definitely helpful for others setting up mocha tests.
Steven Vachon closed this discussion on 21 Nov, 2014 01:45 AM.