Monday, 26 August 2013

Mocha tests unable to

Mocha tests unable to

I'm writing some very simple unit tests in Coffeescript for a Meteor app
using Mocha and getting an error when testing any model which inherits
from another. The simplest example of this can be seen here:
https://gist.github.com/IanWhalen/6342206
When running mocha ./test_class.coffee -r coffee-script I get a successful
result. But when running mocha ./test_subclass.coffee -r coffee-script I
get the following stack trace:
/path_to_app/subclass.coffee:3
unction ctor() { this.constructor = child; } ctor.prototype =
parent.prototype
^
TypeError: Cannot read property 'prototype' of undefined
at __extends (/path_to_app/subclass.coffee:3:199)
at /path_to_app/subclass.coffee:6:5
at Object.<anonymous> (/path_to_app/subclass.coffee:12:5)
at Object.<anonymous> (/path_to_app/subclass.coffee:14:4)
at Module._compile (module.js:456:26)
at Object.loadFile
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19)
at Module.load
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous (/path_to_app/example.coffee:16:14)
at Object.<anonymous> (/path_to_app/example.coffee:24:4)
at Module._compile (module.js:456:26)
at Object.loadFile
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19)
at Module.load
(/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /usr/local/lib/node_modules/mocha/lib/mocha.js:152:27
All of which I assume stems from Mocha not being able to find @Class when
it goes to instantiate @SubClass. Should I be doing something different to
allow me to unit test these models?

No comments:

Post a Comment