Skip to content

Commit 371baf0

Browse files
danny12321nicojs
andauthored
feat(TAP runner): add support for the node TAP runner
Add support for the [node-tap](https://github.com/tapjs/node-tap) test runner with the `@stryker-mutator/tap-runner`. Co-authored-by: Nico Jansen <[email protected]>
1 parent a88744f commit 371baf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+18358
-8203
lines changed

e2e/package-lock.json

+12,892-8,197
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"@types/chai-jest-snapshot": "1.3.6",
1515
"@types/node": "18.15.11",
1616
"@types/semver": "7.3.13",
17+
"@types/tap": "^15.0.7",
1718
"ajv": "8.12.0",
18-
"axios": "1.3.5",
19+
"axios": "1.3.4",
1920
"chai": "4.3.7",
2021
"chai-as-promised": "7.1.1",
2122
"chai-jest-snapshot": "2.0.0",
@@ -39,7 +40,8 @@
3940
"mutation-testing-report-schema": "1.7.14",
4041
"rxjs": "7.8.0",
4142
"semver": "7.3.8",
42-
"ts-jest": "29.1.0",
43+
"tap": "^16.3.2",
44+
"ts-jest": "29.0.5",
4345
"ts-loader": "9.4.2",
4446
"ts-node": "10.9.1",
4547
"typescript": "5.0.4",
@@ -65,6 +67,7 @@
6567
"@stryker-mutator/mocha-runner": "../packages/mocha-runner",
6668
"@stryker-mutator/cucumber-runner": "../packages/cucumber-runner",
6769
"@stryker-mutator/util": "../packages/util",
70+
"@stryker-mutator/tap-runner": "../packages/tap-runner",
6871
"@stryker-mutator/typescript-checker": "../packages/typescript-checker"
6972
}
7073
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "node-tap-javascript",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "A module to perform an integration test",
6+
"type": "module",
7+
"scripts": {
8+
"pretest": "rimraf \"reports\"",
9+
"test": "stryker run",
10+
"test:unit": "tap",
11+
"posttest": "mocha --no-config --no-package --timeout 0 verify/verify.js"
12+
},
13+
"author": "",
14+
"license": "ISC"
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function getCircumference(radius) {
2+
return 2 * Math.PI * radius;
3+
}
4+
5+
export function untestedFunction() {
6+
var i = (5 / 2) * 3;
7+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export function add(num1, num2) {
2+
return num1 + num2;
3+
}
4+
5+
export function addOne(number) {
6+
number++;
7+
return number;
8+
}
9+
10+
export function negate(number) {
11+
return -number;
12+
}
13+
14+
export function notCovered(number) {
15+
return number > 10;
16+
}
17+
18+
export function isNegativeNumber(number) {
19+
let isNegative = false;
20+
if (number < 0) {
21+
isNegative = true;
22+
}
23+
return isNegative;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
3+
"packageManager": "npm",
4+
"testRunner": "tap",
5+
"tempDirName": "stryker-tmp",
6+
"concurrency": 2,
7+
"coverageAnalysis": "off",
8+
"reporters": ["json", "event-recorder", "progress", "html"]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @ts-check
2+
import tap from 'tap';
3+
import { negate, addOne, isNegativeNumber, add } from '../src/math.js';
4+
5+
tap.test('math', (t) => {
6+
t.equal(add(2, 5), 7);
7+
t.equal(addOne(2), 3);
8+
t.equal(negate(2), -2);
9+
t.ok(isNegativeNumber(-2));
10+
t.notOk(isNegativeNumber(0));
11+
t.end();
12+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import tap from 'tap';
2+
import { getCircumference } from '../src/circle.js';
3+
4+
tap.test('circle', (t) => {
5+
t.equal(getCircumference(1), 2 * Math.PI);
6+
t.end();
7+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { expectMetricsJsonToMatchSnapshot } from '../../../helpers.js';
2+
3+
describe('After running stryker with the tap test runner', () => {
4+
it('should report 64% mutation score', async () => {
5+
await expectMetricsJsonToMatchSnapshot();
6+
});
7+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`After running stryker with the tap test runner should report 64% mutation score 1`] = `
4+
Object {
5+
"compileErrors": 0,
6+
"ignored": 0,
7+
"killed": 16,
8+
"mutationScore": 64,
9+
"mutationScoreBasedOnCoveredCode": 94.11764705882352,
10+
"noCoverage": 8,
11+
"runtimeErrors": 0,
12+
"survived": 1,
13+
"timeout": 0,
14+
"totalCovered": 17,
15+
"totalDetected": 16,
16+
"totalInvalid": 0,
17+
"totalMutants": 25,
18+
"totalUndetected": 9,
19+
"totalValid": 25,
20+
}
21+
`;

packages/tap-runner/.mocharc.cjs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
"require": "dist/test/setup.js",
3+
"timeout": 10000,
4+
"forbidOnly": Boolean(process.env.CI)
5+
}

packages/tap-runner/.npmignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
stryker.conf.js
2+
test
3+
dist/test
4+
/schema
5+
/reports
6+
/coverage
7+
/testResources
8+
/typings
9+
/.nyc_output
10+
.vscode
11+
.nycrc.json
12+
*.tsbuildinfo
13+
tsconfig?(.*).json
14+
.mocharc.jsonc
15+
.nyc_output
16+
.gitattributes

packages/tap-runner/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

packages/tap-runner/.nycrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"exclude-after-remap": false,
3+
"check-coverage": true,
4+
"reporter": ["text", "html"],
5+
"report-dir": "reports/coverage",
6+
"lines": 80,
7+
"functions": 80,
8+
"statements": 80,
9+
"branches": 75,
10+
"include": "dist/src/**/*.js"
11+
}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "📼 Unit tests",
11+
"program": "${workspaceFolder}/../../node_modules/mocha/bin/_mocha",
12+
"args": [
13+
"--timeout",
14+
"0",
15+
"--colors",
16+
"${workspaceFolder}/dist/test/unit/**/*.js",
17+
],
18+
"internalConsoleOptions": "openOnSessionStart",
19+
"outFiles": [
20+
"${workspaceRoot}/dist/**/*.js",
21+
"${workspaceFolder}/../test-helpers/dist/**/*.js"
22+
],
23+
"skipFiles": [
24+
"<node_internals>/**"
25+
]
26+
},
27+
{
28+
"type": "node",
29+
"request": "launch",
30+
"name": "📼 Integration tests",
31+
"program": "${workspaceFolder}/../../node_modules/mocha/bin/_mocha",
32+
"args": [
33+
"--timeout",
34+
"0",
35+
"--colors",
36+
"${workspaceFolder}/dist/test/integration/**/*.js",
37+
],
38+
"internalConsoleOptions": "openOnSessionStart",
39+
"outFiles": [
40+
"${workspaceRoot}/dist/**/*.js",
41+
"${workspaceFolder}/../test-helpers/dist/**/*.js"
42+
],
43+
"skipFiles": [
44+
"<node_internals>/**"
45+
]
46+
}
47+
]
48+
}

0 commit comments

Comments
 (0)