Is there a way to get Chai working with asynchronous Mocha tests?

后端 未结 13 2177
自闭症患者
自闭症患者 2020-11-29 21:06

I\'m running some asynchronous tests in Mocha using the Browser Runner and I\'m trying to use Chai\'s expect style assertions:

window.expect = chai.expect;
d         


        
13条回答
  •  情歌与酒
    2020-11-29 21:34

    I asked the same thing in the Mocha mailing list. They basically told me this : to write asynchronous test with Mocha and Chai :

    • always start the test with if (err) done(err);
    • always end the test with done().

    It solved my problem, and didn't change a single line of my code in-between (Chai expectations amongst other). The setTimout is not the way to do async tests.

    Here's the link to the discussion in the mailing list.

提交回复
热议问题