Skip to content

WarleyGabriel/mutation-tests

Repository files navigation

mutation-tests

jest Action Status License

This project is an example of mutation tests with Stryker.
We have a simple method that returns true or false, and we create a test for this method. We have 100% code coverage, but we don't have coverage of all the scenarios.
Look at the Stryker page and get more information about it.

Getting Started

Install the dependencies:

npm install

Compile TypeScript:

npm run build

Running tests

Run tests using Jest:

npm run test
 PASS  dist/test/elections.test.js
  ✓ An 27-year-old cannot be a president (1 ms)
  ○ skipped An 35-year-old can be a president

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line  s
--------------|---------|----------|---------|---------|-------------------
All files     |     100 |      100 |     100 |     100 |
 elections.ts |     100 |      100 |     100 |     100 |
--------------|---------|----------|---------|---------|-------------------

Running mutation tests

Run tests using Stryker:

npm run mutation:test
Ran all tests for this mutant.
Ran 1.00 tests per mutant on average.
--------------|---------|----------|-----------|------------|----------|---------|
File          | % score | killed   | timeout   | survived   | no cov   | error   |
--------------|---------|----------|-----------|------------|----------|---------|
All files     |   60.00 |        3 |         0 |          2 |        0 |       0 |
 elections.ts |   60.00 |        3 |         0 |          2 |        0 |       0 |
--------------|---------|----------|-----------|------------|----------|---------|

Note: There is a test in skip mode, if you remove this skip, we will get 100% coverage after the mutation.

Watch mode

We also have watch mode for Jest and TypeScript:

npm run build:watch
npm run test:watch

About

Mutation tests example with Jest and Stryker

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published