Pedro P
Pedro P

Reputation: 31

How to call await inside mocha root hook plugin

I am using the mocha root hook plugin as this piece of code:

exports.mochaHooks = {
    beforeEach(done) {
        some code
        done();
    },
 };

But now I need to await an async function inside the beforeEach block. How can I do this?

Upvotes: 3

Views: 371

Answers (1)

J.F.
J.F.

Reputation: 15215

The syntaxis is as follow:

beforeEach(async () => {
    await doSomething()
})

Upvotes: 1

Related Questions