jest-runner-mocha
An experimental Mocha runner for Jest
This makes it easy to integrate existing Mocha projects with Jest.
Usage
Install
Install jest
(it needs Jest 21+) and jest-runner-mocha
yarn add --dev jest jest-runner-mocha
npm install --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
Config options
Create a jest-runner-mocha.config.js
at the <rootDir>
or your Jest project.
ui
: (Optional) the UI used by mocha
module.exports = {
ui: 'tdd',
}
compiler
: (Optional) the used for adding a compile step to your mocha tests
module.exports = {
compiler: '/absolute/path/to/babel-register/or/other/compiler',
}
NOTE: Eventually Jest will eventually have an option for configuring runners that will eliminate the need for jest-runner-mocha.config.js
Known issues
- It does not support any Mocha options except for
ui
and compiler
- You can't run it with
jest --coverage
- Support for compilers is very limited.
- Does not support
jest --runInBand