I'm trying to integrate some programmatically generated tests with the Mocha test framework in node.js.
var Promise = require('promise');
var resolved = Promise.resolve(true);
suite("Synchronously defined suite", function() {
test("Synchronously defined test", function() {
return resolved;
});
});
defer(function() {
suite("Asynch DEFINED test", function() {
suiteSetup(function() {
console.log("Asynch setupSuite running...");
});
test("Asynch Test", function() {
console.log("Async test running...");
return resolved;
});
});
});
function defer(fn) {
console.log("Calling defer...");
setTimeout(fn, 100);
}
When I execute this I get:
$ mocha --ui tdd nested-test.js
Calling defer...
Synchronously defined suite
✓ Synchronously defined test
1 passing (4ms)
It seems that Mocha requires that all "suite" functions be executed synchronously at module load time - deferred calls seem to be (silently) ignored (or the program exits before calling them).
Aucun commentaire:
Enregistrer un commentaire