@d-es-ign/stryker-js-core
v9.6.3
Published
The extendable JavaScript mutation testing framework
Maintainers
Readme

StrykerJS
Fork notice
This project is a fork of the corresponding
@stryker-mutatorpackage/repository. Maintenance here is intentionally limited, and this fork only exists while https://github.com/stryker-mutator/stryker-js/pull/5866 has not been accepted and implemented.
Professor X: For someone who hates mutants... you certainly keep some strange company. William Stryker: Oh, they serve their purpose... as long as they can be controlled.
Introduction
For an introduction to mutation testing and StrykerJS features, see stryker-mutator.io.
Getting started
Please follow the quickstart on the website.
For small js projects, you can try the following command:
npm install --save-dev @d-es-ign/stryker-js-core
# Only for small projects:
npx stryker runIt will run stryker with default values:
- Uses
npm testas your test command - Searches for files to mutate in the
libandsrcdirectories
Usage
$ npx stryker <command> [options] [configFile]See usage on stryker-mutator.io
Supported mutators
See our website for the list of currently supported mutators.
Configuration
See configuration on stryker-mutator.io.
Mutation timing diagnostics
For mutation-phase diagnostics, enable the built-in mutation-timings reporter and
set STRYKER_MUTATION_TEST_TIMINGS=1.
Example stryker.conf.json snippet:
{
"reporters": ["progress", "clear-text", "mutation-timings"]
}Environment variables:
STRYKER_MUTATION_TEST_TIMINGS=1enables per-mutantexecutedTestscapture.STRYKER_MUTATION_TEST_TIMINGS_MAX_TESTS=<N>capsexecutedTestslength per mutant.STRYKER_MUTATION_TEST_TIMINGS_FILE=<path>overrides sidecar output path (default:reports/mutation/mutant-test-timings.json).
Programmatic use
Stryker can also be used programmatically from nodejs. It exports 2 classes for you to use: Stryker and StrykerCli.
import { Stryker, StrykerCli } from '@d-es-ign/stryker-js-core';Both classes can be used to run Stryker. The main difference is that Stryker is a slightly more low-level approach, while StrykerCli is the straight up CLI api.
In this example you can see how to use both.
async function main() {
// Runs Stryker as if it was called directly from the cli. Not even returns a promise, it assumes to be allowed to call `process.exit`.
new StrykerCli(process.argv /* RAW argv array */).run();
// Runs Stryker, will not assume to be allowed to exit the process.
const stryker = new Stryker(
{ concurrency: 4 } /* Partial Stryker options object */,
);
const mutantResults = await stryker.runMutationTest();
// mutantResults or rejected with an error.
}Stryker is written in TypeScript, so it is recommended to use Typescript as well to get the best developer experience.
