npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stryker-mutator/typescript

v4.0.0

Published

A plugin for TypeScript-based projects using Stryker

Downloads

22,057

Readme

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
    ]
}