I'm having a problem with TinyTest. I have a test below
Tinytest.add('x - template', function (test) {
var t = new Widget("ddd");
test.equal(t.html,"");
});
and this function in another file (test.js)
function Widget(html){
this.html = html || "";
}
In my package.js :
Package.onTest(function(api) {
api.use('tinytest');
api.use('core:widgets');
api.addFiles('client/test.js');
api.addFiles('widgets-tests.js');
});
I can run my tests but I get this message :
x
FAIL
S: template
- exception - message Widget is not defined
ReferenceError: Widget is not defined
at Package (packages/local-test:core:widgets/widgets-tests.js:12:1)
at [object Object].func (packages/tinytest/tinytest.js:636:1)
at packages/tinytest/tinytest.js:406:1
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at packages/meteor/timers.js:6:1
at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
Thoughts ?
Where are your two files and what are their names? Meteor takes a folder depth + alphabetic order approach to loading javascript files.
Therefore if your Tinytest file is in the same (or any sub) folder as your
test.js
file, and its filename starts with, say, "h", it will load beforetest.js
and won't know about yourTest
function.To make sure your
test.js
file loads first, you should put it either in a folder in the same folder as your Tinytest file. Or, in alib
folder in any parent folder.Learn more about file loading order in Meteor.