Skip to content

Latest commit

 

History

History
94 lines (66 loc) · 2.05 KB

README.md

File metadata and controls

94 lines (66 loc) · 2.05 KB

jest-runner-mocha

Build Status npm version

An experimental Mocha runner for Jest

This makes it easy to integrate existing Mocha projects with Jest.

runner

Usage

Install

Install jest(it needs Jest 21+) and jest-runner-mocha

yarn add --dev jest jest-runner-mocha

# or with NPM

npm install --save-dev jest jest-runner-mocha

Add it to your Jest config

In your package.json

{
  "jest": {
    "runner": "jest-runner-mocha"
  }
}

Or in jest.config.js

module.exports = {
  runner: 'jest-runner-mocha',
}

Run Jest

yarn jest

Options

This project uses cosmiconfig, so you can provide config via:

  • a jest-runner-mocha property in your package.json
  • a jest-runner-mocha.config.js JS file
  • a .jest-runner-mocharc JSON file

In package.json

{
  "jest-runner-mocha": {
    "cliOptions": {
      // Options here
    }
  }
}

or in jest-runner-mocha.config.js

module.exports = {
  cliOptions: {
    // Options here
  }
}

cliOptions

jest-runner-mocha maps some mocha CLI arguments to config options. For example --ui is cliOptions.ui

option example
ui "ui": "tdd"
timeout "timeout": 10000
compiler "compiler": "./path/to/babel-register"
file "file": ["./path/to/include.js", "/supports/multiple/files.js"]

Coverage

Coverage works outside of the box, simply yarn jest -- --coverage

You can also use other Jest options like coveragePathIgnorePatterns and coverageReporters