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

Support for mocha root hooks #232

@fgkolf

Description

@fgkolf

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions