One more Tinytest question…
I ran the following Tinytest code from the Discover Meteor book, along with the following package.js code, and when the tests ran, they passed, but, there was one problem:
The add() test function ran, but the addAsync() function that was supposed to test the Template functionality of the Errors package didn’t run. I checked & double-checked that I didn’t accidentally omit or change anything from the book, but I haven’t been able to figure out why the second test suite didn’t run.
Can anyone see what’s causing the addAsync() set of tests not to run?
Thanks.
errors_test.js
Tinytest.add('Errors --> Collection', function (test) {
test.equal(Errors.collection.find({}).count(), 0);
Errors.throw('A test error!');
test.equal(Errors.collection.find({}).count(), 1);
Errors.collection.remove({});
});
TinyTest.addAsync('Errors --> Template', function(test, done) {
Errors.throw('A new error!');
test.equal(Errors.collection.find({}).count(), 1);
// Render the template
UI.insert( UI.render(Template.meteorErrors, document.body) );
Meteor.setTimeout(function() {
test.equal(Errors.collection.find({}).count(), 0);
done();
}, 3500);
});
package.js
Package.describe({
name: 'thebionicman:errors',
version: '1.0.0',
summary: 'A pattern for displaying application errors to users',
});
Package.onUse(function(api) {
api.versionsFrom('1.1.0.3');
api.use(['minimongo', 'mongo-livedata', 'templating'], 'client');
api.addFiles(['errors.js', 'errors_list.html', 'errors_list.js'], 'client');
if (api.export)
api.export('Errors');
});
Package.onTest(function(api) {
api.use('thebionicman:errors', 'client');
api.use(['tinytest', 'test-helpers'], 'client');
api.addFiles('errors_tests.js', 'client');
});