I am testing stored procedures with mocha running in a nodejs instance. I have this test skeleton:
var chai = require('chai'),
MyReporter = require("../MyReporter.js"),
chokidar = require('chokidar'),
expect = chai.expect,
should = chai.should,
assert = chai.assert;
var Mocha = require('mocha');
amochai = new Mocha({
bail: false,
debug: true
});
amochai.addFile("mytest_v1.js");
function runMocha(callback) {
amochai.run(function () {
callback();
});
}
watcher.on('change', function(path, stats) {
runMocha(function () {});
}
Problem: My tests are always run in an asynchronous mode, although all my tests are written like this:
describe('Mysql stored procedures', function(){
describe('Add this data', function(){
it('-- Should return this information', function(){
// asserts
});
});
});
There is no done() callback, I mean nowhere, so, as it is mentioned everywhere that mocha.js is synchronous by default, what could be the reason why my code is running in a asynchronous mode ?
PATCH
To patch my problem, I had to use before() and check my tests state, but this becomes a nightmare to maintain.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…