So I am trying to run unit tests with Mocha and Chai that are written in CoffeeScript. I know that Mocha has exclude coffeescript since 1.0 so I am passing the compiler flag mocha --compilers coffee:coffee-script
. What ends up happening is that whenever I try to require a file in the test the compiler complains with this error. Otherwise it runs fine.
/usr/local/lib/coffee-script/lib/coffee-script.js:36
throw err;
^
TypeError: In /Users/chietala/workspaces/twl/test/buttonTest.coffee, Array.prototype.indexOf called on null or undefined
at indexOf (native)
at Assign.exports.Assign.Assign.isStatement (/usr/local/lib/coffee-script/lib/nodes.js:1147:72)
at Block.exports.Block.Block.compileNode (/usr/local/lib/coffee-script/lib/nodes.js:262:27)
at Block.exports.Block.Block.compileWithDeclarations (/usr/local/lib/coffee-script/lib/nodes.js:308:19)
at Block.exports.Block.Block.compileRoot (/usr/local/lib/coffee-script/lib/nodes.js:282:19)
at Block.exports.Block.Block.compile (/usr/local/lib/coffee-script/lib/nodes.js:244:21)
at exports.compile.compile (/usr/local/lib/coffee-script/lib/coffee-script.js:31:51)
at Object.require.extensions..coffee (/usr/local/lib/coffee-script/lib/coffee-script.js:13:17)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at /usr/local/lib/node_modules/mocha/bin/_mocha:300:27
at Array.forEach (native)
at load (/usr/local/lib/node_modules/mocha/bin/_mocha:297:9)
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:288:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:487:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
All thats in my test file is the following
ButtonConsumer = require '../button/base/coffee/ButtonConsumer'
And ButtonConsumer looks like this.
class ButtonConsumer
constructor: ->
directory structure is
/
test
buttonTest.coffee
button
base
coffee
ButtonConsumer.coffee
It's pretty bare bones that's why I'm really confused. I'm running Node v0.8.1, Coffeescript v1.2.0, and mocha 1.2.2.
Mocha does not work with CoffeeScript 1.2. Upgraded to 1.3.3 works fine.