包详细信息

@stryker-mutator/typescript

stryker-mutator18.3kApache-2.04.0.0

A plugin for TypeScript-based projects using Stryker

stryker, typescript, @stryker-mutator/transpiler-plugin, @stryker-mutator/mutator-plugin

自述文件

Mutation testing badge Build Status NPM Node version Slack Chat

Stryker

Stryker Typescript

A collection of plugins for native TypeScript support in Stryker, the JavaScript TypeScript Mutation testing framework.

Quickstart

First, install Stryker itself (you can follow the quickstart on the website)

Next, install this package:

npm install --save-dev @stryker-mutator/typescript

Now open up your stryker.conf.js (or stryker.conf.json) file and add the following components:

coverageAnalysis: 'perTest', // Coverage analysis is supported
tsconfigFile: 'tsconfig.json', // Location of your tsconfig.json file
mutator: 'typescript', // Specify that you want to mutate typescript code
transpilers: [
    '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

Peer dependencies

The @stryker-mutator/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:

  • typescript
  • @stryker-mutator/core

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-mutator/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-mutator/typescript' to the list of plugins to load.

3 Plugins

This package contains 3 plugins to support TypeScript

  1. TypescriptOptionsEditor
  2. TypescriptMutator
  3. TypescriptTranspiler

TypescriptOptionsEditor

The TypescriptOptionsEditor 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 TypescriptTranspiler)

Enable the config editor by pointing the tsconfigFile property to your tsconfig location:

// stryker.conf.js
{
 tsconfigFile: 'tsconfig.json',
}

We always override some properties to enforce these rules (see issue 391 to find out why):

allowUnreachableCode: true
noUnusedLocals: false
noUnusedParameters: false

TypescriptMutator

The 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 (or stryker.conf.json) file:

// stryker.conf.js
{
    mutator: 'typescript'
}

TypescriptTranspiler

The 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.

Given your Typescript configuration (see TypescriptOptionsEditor) it generates the javascript output. This is also used to transpile each mutant to javascript. Internally, it uses the same method as Typescript's watch mode (tsc -w), so it can transpile mutants fairly efficiently.

Configure the Typescript transpiler in your stryker.conf.js (or stryker.conf.json) file:

// stryker.conf.js
{
    transpilers: [
        'typescript'
        // You can specify more transpilers if needed
    ]
}

更新日志

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.0 (2020-10-07)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.10 (2020-10-05)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.9 (2020-09-30)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.8 (2020-09-22)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.7 (2020-09-17)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.6 (2020-09-10)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.5 (2020-09-09)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.4 (2020-08-29)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.3 (2020-08-19)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.2 (2020-08-07)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.1 (2020-07-17)

Note: Version bump only for package @stryker-mutator/typescript

4.0.0-beta.0 (2020-07-10)

Features

3.3.1 (2020-07-04)

Note: Version bump only for package @stryker-mutator/typescript

3.3.0 (2020-06-16)

Note: Version bump only for package @stryker-mutator/typescript

3.2.4 (2020-05-18)

Bug Fixes

  • ts: support ts 3.9 on windows in the typescript-transpiler (#2215) (0fab74f)

3.2.3 (2020-05-15)

Note: Version bump only for package @stryker-mutator/typescript

3.2.2 (2020-05-15)

Note: Version bump only for package @stryker-mutator/typescript

3.2.1 (2020-05-15)

Note: Version bump only for package @stryker-mutator/typescript

3.2.0 (2020-05-13)

Features

  • api: Deprecated Config in favor of StrykerOptions (dccdd91)
  • init: add reference to mono schema (#2162) (61953c7)
  • validation: add validation on plugin options (#2158) (d78fe1e)

3.1.0 (2020-03-29)

Bug Fixes

  • api: allow for different api versions of File (#2124) (589de85)

3.0.2 (2020-03-13)

Bug Fixes

  • nodejs requirement: set NodeJS requirement to at least Node 10 (8c08059)

3.0.1 (2020-03-12)

Bug Fixes

3.0.0 (2020-03-11)

Features

  • Initializer: Initialize config file as JSON by default (#2093) (e07d953), closes #2000

2.5.0 (2020-01-12)

Features

  • TypeScript mutator: mutate Array constructor calls without the new keyword (#1903) (aecd944), closes #1902

2.4.0 (2019-11-24)

Features

  • excludedMutations: Implement new naming of mutators (#1855) (c9b3bcb)

2.3.0 (2019-11-13)

Note: Version bump only for package @stryker-mutator/typescript

2.2.1 (2019-11-06)

Note: Version bump only for package @stryker-mutator/typescript

2.2.0 (2019-11-06)

Features

2.1.0 (2019-09-08)

Note: Version bump only for package @stryker-mutator/typescript

2.0.2 (2019-07-11)

Note: Version bump only for package @stryker-mutator/typescript

2.0.1 (2019-07-02)

Note: Version bump only for package @stryker-mutator/typescript

2.0.0 (2019-05-17)

Features

BREAKING CHANGES

  • node 6: support for Node 6 has been dropped. Node 8 or higher is now required.

1.3.1 (2019-04-26)

Note: Version bump only for package @stryker-mutator/typescript

1.3.0 (2019-04-24)

Note: Version bump only for package @stryker-mutator/typescript

1.2.0 (2019-04-02)

Bug Fixes

  • typescript: don't mutate declare statements (#1458) (aae3afe)

1.1.1 (2019-03-21)

Note: Version bump only for package @stryker-mutator/typescript

1.1.0 (2019-03-04)

Bug Fixes

  • duplicate files: make transpile always result in unique file names (#1405) (a3018d2)

1.0.3 (2019-02-26)

Note: Version bump only for package @stryker-mutator/typescript

1.0.2 (2019-02-13)

Bug Fixes

  • stryker init: update metadata for stryker init command (#1403) (38f269b), closes #1402

1.0.1 (2019-02-13)

Note: Version bump only for package @stryker-mutator/typescript

1.0.0 (2019-02-13)

Features

  • rename: rename stryker-xxx-xxx -> [@stryker-mutator](https://github.com/stryker-mutator)/xxx-xxx (1bbd6ff)

BREAKING CHANGES

  • rename: The core package and plugins have been renamed: stryker-typescript -> @stryker-mutator/typescript

0.18.1 (2019-02-12)

Note: Version bump only for package stryker-typescript

0.18.0 (2019-02-08)

Features

  • config-editors: Remove side effects from all config editor plugins (#1317) (1f61bed)
  • mutators: Remove side effects from mutator plugins (#1352) (edaf401)
  • transpilers: Remove side effects transpiler plugins (#1351) (9a8b539)

0.17.0 (2018-12-23)

Features

0.16.2 (2018-12-12)

Note: Version bump only for package stryker-typescript

0.16.1 (2018-11-29)

Bug Fixes

  • stryker-api: Update stryker-api peer dependency version (677fc28)

0.16.0 (2018-11-29)

Bug Fixes

  • String literal mutator: Don't mutate export declarations (c764ccd)

Features

  • Conditional expression mutator: Mutate conditional operators (#1253) (be4c990)

0.15.4 (2018-11-13)

Note: Version bump only for package stryker-typescript

0.15.3 (2018-11-07)

Note: Version bump only for package stryker-typescript

0.15.2 (2018-10-15)

Bug Fixes

  • any-promise: Don't register a promise implementation (#1180) (1d3e2f6)
  • version: Version bump for failed release (8cf9e87)

0.15.0 (2018-10-06)

Features

0.14.2 (2018-10-03)

Note: Version bump only for package stryker-typescript

0.14.1 (2018-09-30)

Bug Fixes

  • mutator: Fix empty case statement unkillable mutant (#1159) (e080acb)

0.14.0 (2018-09-14)

Features

  • mutator: add SwitchCase statement mutator (#1127) (cec6a39)

0.13.2 (2018-08-28)

Note: Version bump only for package stryker-typescript

0.13.1 (2018-08-21)

Note: Version bump only for package stryker-typescript

0.13.0 (2018-08-19)

Features

  • stryker config: rename config setting reporter to reporters (#1088) (584218a), closes #793

0.12.2 (2018-08-17)

Bug Fixes

  • dependencies: support stryker-api 0.19.0 (#1087) (44ce923)

0.12.1 (2018-08-17)

Note: Version bump only for package stryker-typescript

0.12.0 (2018-07-20)

Bug Fixes

Features

0.11.3 (2018-07-04)

Note: Version bump only for package stryker-typescript

0.11.2 (2018-05-31)

Bug Fixes

  • String mutator: do not mutate prologue directives (#829) (6e80251)

0.11.1 (2018-05-21)

Note: Version bump only for package stryker-typescript

0.11.0 (2018-04-30)

Features

BREAKING CHANGES

  • node version: Node 4 is no longer supported.

0.10.2 (2018-04-20)

Bug Fixes

  • String mutator: do not mutate jsx attributes (#711) (6656621), closes #701

0.10.1 (2018-04-11)

Bug Fixes

0.10.0 (2018-04-04)

Features

  • files: use tsconfig to determine which files to transpile (bc02c64)

BREAKING CHANGES

  • files: If you want to override compiler options for Stryker, use the tsconfig.options key instead of tsconfig.

0.9.4 (2018-03-22)

Bug Fixes

  • peerDependency: update stryker-api requirement to ^0.14.0 (3ce04d4)

0.9.3 (2018-03-22)

Note: Version bump only for package stryker-typescript

0.9.2 (2018-03-21)

Note: Version bump only for package stryker-typescript

0.9.1 (2018-02-07)

Bug Fixes

  • dependencies: update stryker-api requirement to ^0.13.0 (8eba6d4)

0.9.0 (2018-02-07)

Features

  • coverage analysis: Support transpiled code (#559) (7c351ad)

0.8.3 (2018-01-12)

Note: Version bump only for package stryker-typescript

0.8.2 (2018-01-10)

Note: Version bump only for package stryker-typescript

0.8.1 (2017-12-21)

Note: Version bump only for package stryker-typescript

0.8.0 (2017-12-07)

Features

0.7.1 (2017-11-27)

Note: Version bump only for package stryker-typescript

0.7.0 (2017-11-24)

Features

  • JavaScript mutator: Add stryker-javascript-mutator package (#467) (06d6bac), closes #429

0.6.0 (2017-11-17)

Bug Fixes

  • stryker-typescript: Add support for header files (#451) (517db10), closes #443

Features

  • typescript-mutation: Add a StringLiteral mutator. (#461) (43c581c)

0.5.0 (2017-11-14)

Features

  • typescript-mutator: Implement new ArrowFunctionMutator (#460) (d5fe462), closes #456

0.4.1 (2017-11-14)

Bug Fixes

0.4.0 (2017-11-13)

Features

0.3.0 (2017-10-24)

Features

  • transpiler api: Async transpiler plugin support (#433) (794e587)

0.2.0 (2017-10-20)

Bug Fixes

  • homepage: Set correct hompage in package.json (#424) (30e563b)

0.1.0 (2017-10-03)

Features

  • typescript: Force no code quality compiler options (#393) (3445cbf)

0.0.2 (2017-09-22)

Bug Fixes

  • package.json: Add dependency to tslib. (#387) (fcc8b88)

0.0.1 (2017-09-19)

Features

  • typescript: Add support for TypeScript mutation testing (#376) (ba78168)

BREAKING CHANGES

  • typescript: * Hoist the Mutator interface to a higher abstraction. With this interface it was possible to add mutators for specific ES5 AST nodes. As we're moving away from ES5, this plugin abstraction had to be hoisted to a higher level. It is no longer possible to plugin a specific ES5 node mutator.
  • Update report interface: Rename MutantState.Error => MutantState.RuntimeError.