1

I am trying to rerun mocha tests using supervisor. I have tried:

supervisor node_modules\.bin\mocha

It goes into loop with error:

basedir=`dirname "$0"`

Suggestions?

Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997
Larry Eitel
  • 1,337
  • 5
  • 17
  • 35

1 Answers1

3

I think all you want to do is mocha -w:

-w, --watch                     watch files for changes

It works nicely with the dot-matrix reporter (default) and -G to give you growl notifications when your tests fail.

Edit:

I've found the Windows-related issues you mention: "No such module" error when trying to get Mocha to watch my project

I can't help with that, either.

But back to the supervisor question: When I install mocha, the "bin" script is in node_modules/mocha/bin, and I can get tests to run repeatedly with the following

supervisor node_modules/mocha/bin/mocha 

supervisor does print some annoying DEBUG lines between each test run, but those can be silenced with --quiet. Because mocha quits after each run, you have a busy loop of constant tests, though.

Community
  • 1
  • 1
rdrey
  • 8,529
  • 3
  • 34
  • 50
  • I tried that but I get: var b = process.binding('signal_watcher'); Error: No such module at process.startup.processSignalHandlers.process.on.process.addListener (node.js:468:27) I understand it is a Windows issue and I have tried the work around. It resolves the error ok but then it is not successfully WATCHING for changes. I have to restart mocha to rerun tests. This is why I was trying a 'supervisor' approach. – Larry Eitel Aug 05 '12 at 22:29
  • When I run quiet, it still doesn't rerun tests. An error is interfering. Trying a variety of approaches. I am running: supervisor node node_modules/mocha/bin/mocha --require should --require server. It complains with: events.js:66 throw arguments[1]; // Unhandled 'error' event Error: listen EADDRINUSE – Larry Eitel Aug 06 '12 at 02:41
  • EADDRINUSE is usually a sign that the port you're trying to open is already used by another program. In your case you probably have your Express app running in a command line somewhere, and your tests are trying to start the same Express app on the same port, but can't. – rdrey Aug 06 '12 at 05:57
  • I just realized that. Cake is launching on port 3000. So I launched manually like node server.js. Then I manually changed port to 3001 so that when test goes to launch server, it uses another port. I still was unable to get supervisor to work. I WAS ABLE however to use nodemon like: nodemon node_modules/mocha/bin/mocha --require should --require server. I will have to set ENV var to test or something so that it will use diff port for testing. Thank you for your input along the way. – Larry Eitel Aug 06 '12 at 06:08
  • One 'minor' detail is that I CANNOT see which test failed. It just says: ? 1 of 2 tests failed: ... [nodemon] app crashed - waiting for file changes before starting... – Larry Eitel Aug 06 '12 at 06:15
  • which `mocha reporter` are you using? some of them provide far more details than others. But maybe nodemon is trimming your output for you when it restarts an app... can't really tell. – rdrey Aug 06 '12 at 06:38