Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stryker

Package Overview
Dependencies
Maintainers
2
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stryker

The extendable JavaScript mutation testing framework

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
399
decreased by-39.08%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status NPM Gitter

Stryker

Stryker

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.

Work in progress

This repository is a work in progress. We only support Jasmine tests in the browser for now. Please create and vote on issues to help us determine the priority on features.

Getting started

Stryker is a mutation testing framework for JavaScript. It allows you to test your test by temporarily inserting bugs.

To install stryker, execute the command:

npm install stryker --save-dev

Note*: During the installation you may run into errors caused by node-gyp. It is safe to ignore these errors.*

To test if stryker is working, execute the command:

node node_modules/stryker/dist/src/Stryker.js --help

Usage

Stryker can be used in two ways:

  1. Using a config file
node node_modules/stryker/src/Stryker.js -c stryker.conf.js
  1. Using command line arguments
node node_modules/stryker/src/Stryker.js –m src/myFirstFile.js,src/mySecondFile.js –f libs/externalLibrary.js,src/myFirstFile.js,src/mySecondFile.js,test/*.js

The config file is not a simple json file, it should be a common js (a.k.a. npm) module looking like this:

module.exports = function(config){
  config.set({
    // Your config here
  });
}

You might recognize this way of working from the karma test runner.

If both the config file and command line options are combined, the command line arguments will overrule the options in the config file.

All options are optional except the files (or -f) and mutate (or -m) options. With files you configure all files needed to run the tests, except the test framework files themselves (jasmine). The order in this list is important, because that will be the order in which the files are loaded. With mutate you configure the subset of files to target for mutation. These should be your source files.

Both the files and mutate options are a list of globbing expressions. The globbing expressions will be resolved using node glob. This is the same globbing format you might know from Grunt and Karma. The way to provide this list is as an array in the config file, or as a comma seperated list on the command line (without spaces or quotes)

Configuration

Options can be configured either via the command line or via a config file.

Avalailable options

Files to mutate

Short notation: -m
Full notation: --mutate
Config file key: mutate
Description:
A comma seperated list of globbing expressions used for selecting the files that should be mutated.
Example: -m src/**/*.js,a.js`

All files

Short notation: -f
Full notation: --files
Config file key: files
Description:
A comma seperated list of globbing expressions used for selecting all files needed to run the tests. These include: test files, library files, source files (the files selected with --mutate) and any other file you need to run your tests. The order of the files specified here will be the order used to load the file in the test runner (karma).
Example: -f node_modules/a-lib/\*\*/\*.js,src/\*\*/\*.js,a.js,test/\*\*/\*.js

Log level

Short notation: (none)
Full notation: --logLevel
Config file key: logLevel
Description:
Set the log4js loglevel. Possible values: fatal, error, warn, info, debug, trace, all and off. Default is "info" Note: We are still migrating to using log4js. Some messages are not configurable

Config file

Short notation: -c
Full notation: --configFile
Description:
A location to a config file. That file should export a function which accepts a "config" object. On that object you can configure all options as an alternative for the command line. If an option is configured on both the command line and in the config file, the command line wins. An example config:

module.exports = function(config){
  config.set({
    files: ['../../../sampleProject/src/?(Circle|Add).js', '../../../sampleProject/test/?(AddSpec|CircleSpec).js'],
    mutate: ['../../../sampleProject/src/?(Circle|Add).js'],
    logLevel: 'debug'
  });
}

Supported mutations

Math

OriginalMutated
a + ba - b
a - ba + b
a * ba / b
a / ba * b
a & ba * b

Unary

OriginalMutated
a++a--
a--a++
++a--a
--a++a
+a-a
-a+a

Conditional boundary

OriginalMutated
a < ba <= b
a <= ba < b
a > ba >= b
a >= ba < b

Reverse conditional

OriginalMutated
a == ba != b
a != ba == b
a === ba !== b
a !== ba === b
a <= ba > b
a >= ba < b
a < ba >= b
a > ba <= b
a && ba || b
a || ba && b

Remove conditionals

OriginalMutated
for (var i = 0; i < 10; i++) { }for (var i = 0; false; i++) { }
while (a > b) { }while (false) { }
do { } while (a > b);do { } while (false);
if (a > b) { }if (true) { }
if (a > b) { }if (false) { }

Keywords

FAQs

Package last updated on 17 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc