我try 在mocha中测试一个中间件. 问题是,在执行它们的回调之前,所有的"it"调用都在等待前一个调用完成.
it(`should trigger pre hook 1`, (done) => {
use((next) => {
setTimeout(() => {
done();
next();
}, 1000);
});
});
it(`should trigger pre hook 2`, (done) => {
use((next) => {
setTimeout(() => {
done();
next();
}, 1000);
});
});
start(() => {
// middleware done
});
The second it(...)
waits for the first to complete.
And thats exactly the problem, since the second use(...)
is not called before i fire the start(...)
function, so it never gets executed and the test fails.
我如何才能告诉mocha执行所有"it"回调,而不是等待前一个回调完成(或失败)?