UNPKG

2.92 kBMarkdownView Raw
1
2[![Build Status](https://travis-ci.org/stryker-mutator/stryker.svg?branch=master)](https://travis-ci.org/stryker-mutator/stryker)
3[![NPM](https://img.shields.io/npm/dm/@stryker-mutator/javascript-mutator.svg)](https://www.npmjs.com/package/@stryker-mutator/javascript-mutator)
4[![Node version](https://img.shields.io/node/v/@stryker-mutator/javascript-mutator.svg)](https://img.shields.io/node/v/@stryker-mutator/javascript-mutator.svg)
5[![Gitter](https://badges.gitter.im/stryker-mutator/stryker.svg)](https://gitter.im/stryker-mutator/stryker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6[![BCH compliance](https://bettercodehub.com/edge/badge/stryker-mutator/stryker)](https://bettercodehub.com/)
7
8![Stryker](https://github.com/stryker-mutator/stryker/raw/master/stryker-80x80.png)
9
10# Stryker JavaScript mutator
11
12A mutator that supports JavaScript for [Stryker](https://stryker-mutator.io), the JavaScript Mutation testing framework. This plugin does not transpile any code. The code that the @stryker-mutator/javascript-mutator gets should be executable in your environment (i.e. the @stryker-mutator/javascript-mutator does not add support for Babel projects).
13
14## Quickstart
15
16First, install Stryker itself (you can follow the [quickstart on the website](https://stryker-mutator.io/quickstart.html))
17
18Next, install this package:
19
20```bash
21npm install --save-dev @stryker-mutator/javascript-mutator
22```
23
24Now open up your stryker.conf.js file and add the following components:
25
26```javascript
27mutator: 'javascript',
28// OR
29mutator: {
30 name: 'javascript',
31 plugins: ['classProperties', 'optionalChaining'],
32 excludedMutations: ['BooleanSubstitution', 'StringLiteral']
33}
34```
35
36Now give it a go:
37
38```bash
39$ stryker run
40```
41
42## Configuration
43
44### `mutator.name` [`string`]
45
46The name of the mutator, use `'javascript'` to enable this mutator.
47
48### `mutator.plugins` [`(string | ParserPluginWithOptions)[]`]
49
50Default: `['asyncGenerators', 'bigInt', 'classProperties', 'dynamicImport', 'flow', 'jsx', 'objectRestSpread', ['decorators', { decoratorsBeforeExport: true }]`
51
52Configure custom [Babel Syntax plugins](https://babeljs.io/docs/en/babel-parser#plugins). Syntax plugins allow you to parse different pieces of syntax.
53By default a number of plugins are configured. We might add more in the future. For example: you can configure your own Syntax plugins here to allow for [stage 1](https://github.com/tc39/proposals/blob/master/stage-1-proposals.md) features.
54
55### `mutator.excludedMutations` [`string[]`]
56
57See [Stryker core's readme](https://github.com/stryker-mutator/stryker/tree/master/packages/core#mutator)
58
59## Mutators
60
61The `JavaScript Mutator` is a plugin to mutate JavaScript code. This is done using Babel without any plugins.
62
63See [test code](https://github.com/stryker-mutator/stryker/tree/master/packages/javascript-mutator/test/unit/mutators) to know which mutations are supported.