In mocha framework, you can setup/arrange preconditions by using before() beforeEach(), in describe and before it.
The sequence of these hooks are: all before() run once, then beforeEach(), tests, afterEach90, and finally after() run once.
If you want your asynchronous arrange to be completed before everything else happens, you need to use the done parameter in your before request, and call it in the callback.
Mocha will then wait until done is called to start processing the following blocks.
1 | before(function (done) { |
using async/await
1 | before(async () => { |