Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rogeliog/jest-runner-mocha
A Mocha runner for Jest
https://github.com/rogeliog/jest-runner-mocha
jest mocha
Last synced: 12 days ago
JSON representation
A Mocha runner for Jest
- Host: GitHub
- URL: https://github.com/rogeliog/jest-runner-mocha
- Owner: rogeliog
- Created: 2017-09-01T17:40:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T12:09:18.000Z (almost 5 years ago)
- Last Synced: 2024-10-13T22:35:05.853Z (26 days ago)
- Topics: jest, mocha
- Language: JavaScript
- Homepage:
- Size: 150 KB
- Stars: 71
- Watchers: 8
- Forks: 12
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
- awesome-jest - jest-runner-mocha
README
[![Build Status](https://travis-ci.org/rogeliog/jest-runner-mocha.svg?branch=master)](https://travis-ci.org/rogeliog/jest-runner-mocha) [![npm version](https://badge.fury.io/js/jest-runner-mocha.svg)](https://badge.fury.io/js/jest-runner-mocha)
jest-runner-mocha
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`
```bash
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`
```json
{
"jest": {
"runner": "jest-runner-mocha"
}
}
```Or in `jest.config.js`
```js
module.exports = {
runner: 'jest-runner-mocha',
}
```### Run Jest
```bash
yarn jest
```## Options
This project uses [cosmiconfig](https://github.com/davidtheclark/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 fileIn `package.json`
```json
{
"jest-runner-mocha": {
"cliOptions": {
// Options here
},
"coverageOptions": {
// Options here
}
}
}
```or in `jest-runner-mocha.config.js`
```js
module.exports = {
cliOptions: {
// Options here
},
"coverageOptions": {
// 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"`]### coverageOptions
jest-runner-mocha has some optional configuration for code coverage
|option|example|description|
|-----|-----|-----|
|useBabelRc|`"useBabelRc": true`|read .babelrc when instrumenting for code coverage (required if you transpile your code with babel).|### Coverage
Coverage works outside of the box, simply `yarn jest -- --coverage`
You can also use other Jest options like [coveragePathIgnorePatterns](http://facebook.github.io/jest/docs/en/configuration.html#coveragepathignorepatterns-array-string) and [coverageReporters](http://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string)