-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Correct way of using nodemon with test runners? #496
Comments
Here's the output, btw. As you can see, I use a script defined in package.json to run nodemon and mocha ( $ npm run test-dev
> funkis@0.1.4 test-dev /Users/mstade/dev/funkis
> nodemon -x "_mocha -R min $@"
8 Feb 15:57:48 - [nodemon] v1.3.6
8 Feb 15:57:48 - [nodemon] to restart at any time, enter `rs`
8 Feb 15:57:48 - [nodemon] watching: *.*
8 Feb 15:57:48 - [nodemon] starting `_mocha -R min `
545 passing (670ms)
2 failing
1) Protocol when called with an empty signatures object should throw a TypeError:
AssertionError: function (rest) { return apply(fn, this, argc, arguments) } must throw function TypeError() { [native code] }
at Context.<anonymous> (/Users/mstade/dev/funkis/test/Protocol.js:15:39)
at Test.Runnable.run (/Users/mstade/dev/funkis/node_modules/mocha/lib/runnable.js:221:32)
at Runner.runTest (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:374:10)
at /Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:452:12
at next (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:299:14)
at /Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:309:7
at next (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:247:23)
at Immediate._onImmediate (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:321:17)
2) Protocol when called with a name, and some signatures should set immutable and enumerable properties on the protocol:
TypeError: Signatures must be an object.
at TypeError (native)
at new Protocol (/Users/mstade/dev/funkis/lib/Protocol.js:8:34)
at Protocol (/Users/mstade/dev/funkis/lib/Protocol.js:5:12)
at Context.<anonymous> (/Users/mstade/dev/funkis/test/Protocol.js:21:15)
at Test.Runnable.run (/Users/mstade/dev/funkis/node_modules/mocha/lib/runnable.js:221:32)
at Runner.runTest (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:374:10)
at /Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:452:12
at next (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:299:14)
at /Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:309:7
at next (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:247:23)
at Immediate._onImmediate (/Users/mstade/dev/funkis/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:321:17)
util.error: Use console.error instead
[nodemon] failed to start process, possible issue with exec arguments
exception in nodemon killing node
Error: Uncaught, unspecified "error" event.
at Error (native)
at emit (events.js:78:13)
at ChildProcess.<anonymous> (/Users/mstade/dev/funkis/node_modules/nodemon/lib/monitor/run.js:133:11)
at ChildProcess.emit (events.js:101:17)
at Process.ChildProcess._handle.onexit (child_process.js:1038:12)
----------------------------------------------------------
If appropriate, please file an error with the output from:
$ node /Users/mstade/dev/funkis/node_modules/.bin/nodemon -x _mocha -R min --dump
At http://github.com/remy/nodemon/issues/new
----------------------------------------------------------
npm ERR! Darwin 14.1.0
npm ERR! argv "/usr/local/opt/nvm/versions/io.js/v1.0.4/bin/iojs" "/usr/local/opt/nvm/versions/io.js/v1.0.4/bin/npm" "run" "test-dev"
npm ERR! node v1.0.4
npm ERR! npm v2.3.0
npm ERR! code ELIFECYCLE
npm ERR! funkis@0.1.4 test-dev: `nodemon -x "_mocha -R min $@"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the funkis@0.1.4 test-dev script 'nodemon -x "_mocha -R min $@"'.
npm ERR! This is most likely a problem with the funkis package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodemon -x "_mocha -R min $@"
npm ERR! You can get their info via:
npm ERR! npm owner ls funkis
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/mstade/dev/funkis/npm-debug.log |
Yeah, this should work. I do something similar on other projects. I've got a feeling it's to do with the |
I use it sometimes to scope which tests get run, and to pass additional parameters to Mocha should I need to. But that works fine, this only ever fails whenever there are exceptions in my code, either because I throw them myself or because of booboos. I previously used I'll see if I can come up with a smaller repro case in the next few days. I'd like to say I'd also be able too see about a fix and a PR, but I fear I probably won't have time for that so would rather not overpromise. |
@mstade I think this is a regression with 1.3.x. Made me go back to 1.2.x. |
I encounter the same problem when i do $npm run test
My package.json script
|
For anyone coming in later, you can work-around this issue by just appending nodemon --exec "your_command_stuff || true" |
It looks like this is a duplicate of #627 where they report this happens specifically when the processes exits with error code 2. |
@jayphelps thank you very much. my test script looks like this, hopefully, it will help someone!
|
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
Try using this
do not use single or double quotes |
Only exit after code 2 if it happened quickly; improve messaging (recommend `||exit 1`) If nodemon exits _quickly_ on code 2, then it'll bail and warn. If it's after ~500ms, then it assumes that the sub-process intentionally used exit 2 (like mocha or stylelint), it won't bail and treat it as a failure (like a crash). Props to @joeytwiddle Fixes #496 Fixes #627
And if you run:
Saving your file twice quickly will run the tests twice as well, which might be undesirable. |
This worked for me: |
When running tests using mocha or the likes, if the tests fail, and thus the runner exits with a non-zero status code, nodemon seems to think there's something broken with the process and dies without watching for changes. Is there a way to opt out of this behavior?
The text was updated successfully, but these errors were encountered: