visionmedia/mocha — Issue #262: Tests don't pass with --watch
Author: GraemeF
Created: 2012-02-12 13:57:45+00:00
State: open

I've cloned the mocha repository and `bin/mocha` shows all 62 tests are passing. If I run `bin/mocha --watch` and make a whitespace change to a source file then I get 13 failures with the following output:

$ bin/mocha --watch

.............

✖ 13 of 62 tests failed:

1) Runnable(title, fn) #timeout(ms) should set the timeout:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

2) Runnable(title, fn) .title should be present:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

3) Runnable(title, fn) when arity >= 1 should be .async:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

4) Runnable(title, fn) when arity == 0 should be .sync:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

5) Runnable(title, fn) .run(fn) when .pending should not invoke the callback:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

6) Runnable(title, fn) .run(fn) when sync without error should invoke the callback:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

7) Runnable(title, fn) .run(fn) when sync when an exception is thrown should invoke the callback:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

8) Runnable(title, fn) .run(fn) when async without error should invoke the callback:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

9) Runnable(title, fn) .run(fn) when async when the callback is invoked several times without an error should emit a single "error" event:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

10) Runnable(title, fn) .run(fn) when async when the callback is invoked several times with an error should emit a single "error" event:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

11) Runnable(title, fn) .run(fn) when async when an exception is thrown should invoke the callback:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

12) Runnable(title, fn) .run(fn) when async when an error is passed should invoke the callback:
TypeError: Cannot call method 'test' of undefined
at Runner.runTest (/home/graeme/Development/mocha/lib/runner.js:268:14)
at /home/graeme/Development/mocha/lib/runner.js:316:12
at next (/home/graeme/Development/mocha/lib/runner.js:199:14)
at /home/graeme/Development/mocha/lib/runner.js:208:7
at next (/home/graeme/Development/mocha/lib/runner.js:157:23)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

13) serial "before each" hook:
TypeError: Cannot call method 'test' of undefined
at next (/home/graeme/Development/mocha/lib/runner.js:159:14)
at Array.0 (/home/graeme/Development/mocha/lib/runner.js:176:5)
at EventEmitter._tickCallback (node.js:192:40)

I'm getting similar errors with my own tests, again only when using `--watch`, especially `TypeError: Cannot call method 'test' of undefined`.