This package has been deprecated
Stryker v1 is released, but you're still using a 0.x version. This version is no longer maintained. Please use @stryker-mutator/typescript. See https://stryker-mutator.io/blog/2019-02-13/announcing-stryker-1-0 for the full migration guide.
stryker-typescript0.18.1 • Public • Published
A collection of plugins for native TypeScript support in Stryker, the
First, install Stryker itself (you can follow the quickstart on the website)
Next, install this package:
npm install --save-dev stryker-typescript
Now open up your stryker.conf.js file and add the following components:
coverageAnalysis: 'off' // Coverage analysis with a transpiler is not supported a.t.m.tsconfigFile: 'tsconfig.json' // Location of your tsconfig.json filemutator: 'typescript' // Specify that you want to mutate typescript codetranspilers:'typescript' // Specify that your typescript code needs to be transpiled before tests can be run. Not needed if you're using ts-node Just-in-time compilation.
Now give it a go:
$ stryker run
stryker-typescript package is collection a plugins for
stryker to enable
typescript support. As such, you should make sure you have the correct versions of its dependencies installed:
For the current versions, see the
peerDependencies section in the package.json.
These are marked as
peerDependencies so you get a warning during installation when the correct versions are not installed.
Load the plugins
In order to use one of the
stryker-typescript's plugins it must be loaded into Stryker.
The easiest way to achieve this, is not have a
plugins section in your config file. That way, all
node_modules starting with
stryker- will be loaded.
If you do decide to choose specific modules, don't forget to add
'stryker-typescript' to the list of plugins to load.
This package contains 3 plugins to support TypeScript
TypescriptConfigEditor is a handy plugin that reads your tsconfig.json file and loads it into stryker.conf.js. It will capture all your tsconfig settings to the
tsconfig in stryker (this property is later used by the
TypescriptMutator and the
Enable the config editor by pointing the
tsconfigFile property to your tsconfig location:
// stryker.conf.jstsconfigFile: 'tsconfig.json'
We always override some properties to enforce these rules (see issue 391 to find out why):
allowUnreachableCode: truenoUnusedLocals: falsenoUnusedParameters: false
TypescriptMutator is a plugin to mutate typescript code. It builds a Typescript Abstract Syntax Tree (AST) and mutates your code using different kind of mutators.
See test code to know which mutations are supported.
Configure the Typescript mutator in your stryker.conf.js file:
// stryker.conf.jsmutator: 'typescript'
TypescriptTranspiler is a plugin to transpile typescript source code before running tests. If you're using a bundler you might want to configure that instead.
tsc -w), so it can transpile mutants fairly efficiently.
Configure the Typescript transpiler in your stryker.conf.js file:
// stryker.conf.jstranspilers:'typescript'// You can specify more transpilers if needed