How can I build my test suite asynchronously?

后端 未结 3 1534
鱼传尺愫
鱼传尺愫 2020-11-28 17:16

I\'m trying to create mocha tests for my controllers using a config that has to be loaded async. Below is my code. However, when the mocha test is run, it doesn\'t run any

3条回答
  •  半阙折子戏
    2020-11-28 17:27

    You could just separate the logic of testing and loading entirely, wrap the loader in a promise that blocks the test until the config is executed (very straightforward with async/await if you're using node8, otherwise just Promise.each the results).

    If you really dont wanna do that you could Promisify your testing framework, which would then allow you to treat all describe/it blocks as asynchronous code.

提交回复
热议问题