As of mocha v8, it supports root hooks https://mochajs.org/#root-hook-plugins in order to be able to globally define before and after hooks that run either once before/after your suite or before/after each test.
Following the guides to create such a root hook i ended up with the following configuration:
// hooks.js
exports.mochaHooks = {
beforeAll() {
// my setup code here
}
};
But it didn't seem to work and my beforeAll hook never run. I also tried to specify a --require hooks.js in a mocha.opts file and then include it in my karma config as shown in the docs:
As of mocha v8, it supports root hooks https://mochajs.org/#root-hook-plugins in order to be able to globally define before and after hooks that run either once before/after your suite or before/after each test.
Following the guides to create such a root hook i ended up with the following configuration:
But it didn't seem to work and my
beforeAll
hook never run. I also tried to specify a--require hooks.js
in amocha.opts
file and then include it in my karma config as shown in the docs:Again my global hook never run. Any insights on this?