testingMicrosoft Bot Frameworkasynchronous回复

我正在使用Mocha和Chai(BDD模式)testing我的Bot。

我想从事件发射器收听,看看我收到了哪些回复,并根据我发送的文本判断是否有意义。

我的testing通常遵循这个模式:

beforeEach(function (done) { bot = require('myModule').textBot; bot.removeAllListeners('reply'); done(); }); describe('', function(){ it('', function (done) { bot.on('reply', function (message) { assert.include(message.text.toLowerCase(), ''); done(); }); bot.processMessage({text: 'message_that_will_trigger'}); }); }); 

我有多个描述和多个我的testing。 有时,错误的回复回复会触发回复(即使我重置beforeEach上的所有callback),所以testing将会失败。

如果我只运行特定的testing。 他们通过。

这是testing这个最好的方法吗? 我该如何解决这个问题?

如果有人绊倒在这。 确保在“完成”调用之前断言某个事物…

我有一个testing,没有断言任何东西,显然是搞砸了其他testing。 取消testing后,一切顺利。