Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Support for mocha root hooks #232

Open
fgkolf opened this issue Nov 5, 2020 · 0 comments
Open

Support for mocha root hooks #232

fgkolf opened this issue Nov 5, 2020 · 0 comments

Comments

@fgkolf
Copy link

fgkolf commented Nov 5, 2020

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
  }
};
// karma.config.js
 client: {
      mocha: {
        require: 'hooks.js'
      }
 }

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:

// karma.config.js
 client: {
      mocha: {
        opts: 'mocha.opts'
      }
 }

Again my global hook never run.
Any insights on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant