I am trying to play around with mocha running on node under Windows. I've also decided why not throw some CoffeeScript in for fun.
describe 'Array', ->
describe '#indexOf()', ->
it 'should return -1 when not present' ->
[1,2,3].indexOf(4).should.equal -1
The problem is that I am running into an error:
C:\Users\ShaneC\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\coffee-script.js:51
throw err;
^
Error: In C:\projects\BowlingKata\test\test.coffee, Parse error on line 3: Unexpected '->'
at Object.parseError (C:\Users\ShaneC\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\parser.js:477:11)
at Object.parse (C:\Users\ShaneC\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\parser.js:554:22)
at C:\Users\ShaneC\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\coffee-script.js:43:20
at Object..coffee (C:\Users\ShaneC\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\coffee-script.js:19:17)
at Module.load (module.js:353:31)
This is my mocha.opts file:
--reporter spec
--ui bdd
-r should
--compilers coffee:coffee-script
Any ideas on what I could be doing wrong? I've copied the code from http://net.tutsplus.com/tutorials/javascript-ajax/better-coffeescript-testing-with-mocha/ and nobody there is reporting any issues..
Assuming that you are calling a function it
, with arguments "should return -1 when not present", and then a function to check this on, you need to separate the arguments with commas:
describe 'Array', ->
describe '#indexOf()', ->
it 'should return -1 when not present', ->
[1,2,3].indexOf(4).should.equal -1
This compiles to:
describe('Array', function() {
return describe('#indexOf()', function() {
return it('should return -1 when not present', function() {
return [1, 2, 3].indexOf(4).should.equal(-1);
});
});
});