call done() multiple times breaks tests workflow
Closed this issue · 0 comments
AlexeyKhristov commented
If done() function called multiple times - should() function called several times or never called at all, depends on previous flow.
My expectations - receive mocha like error: "Uncaught Error: done() called multiple times" or second call have no effect at all
Broke cases:
Case 1:
"use strict";
var expect = require("chai").expect;
var machiatto = require("machiatto");
var spec = machiatto("check flow tests");
spec
.when('async when', function (context, done) {
setTimeout(done, 1000);
setTimeout(done, 2000);
})
.should('should N1', function (context) {
console.log('should N1');
expect(true).to.be.ok;
})
.should('should common', function (context) {
console.log('should common');
expect(false).to.be.false;
});
module.exports = spec;
I expect what should "should N1" called once and should "should common" called once.
Result - "should N1" called twice, "should common" never called
Case 2:
"use strict";
var expect = require("chai").expect;
var machiatto = require("machiatto");
var spec = machiatto("check flow tests");
spec
.when('async when', function (context, done) {
setTimeout(done, 1000);
setTimeout(done, 2000);
})
.should('should N1', function (context) {
console.log('should N1');
expect(true).to.be.ok;
})
.should('should common', function (context) {
console.log('should common');
expect(false).to.be.false;
});
spec
.when('async when', function (context, done) {
setTimeout(done, 2000);
})
.should('should N2', function (context) {
console.log('should N2');
expect(true).to.be.ok;
})
.should('should common', function (context) {
console.log('should common');
expect(false).to.be.false;
});
module.exports = spec;
In this case I expect "should 2" and "should common" called one time, but
result is: "should common" called twice and "should N2" never called. Additionally but with "should 1" repeated