-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tap-runner): support
"nodeArgs"
(#4235)
Add support for the `tap.nodeArgs` config option. Here you can specify additional node arguments to be passed to every test runner. With this, it is now possible to JIT compile typescript code using: ```json { "tap": { "nodeArgs": ["--loader", "ts-node/esm"] } } ``` Or (when using commonjs) ```json { "tap": { "nodeArgs": ["-r", "ts-node/register"] } } ``` Also add a test for typescript using the tap runner.
- Loading branch information
Showing
35 changed files
with
686 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "tap-typescript", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "A project using node-tap and typescript", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"pretest": "rimraf \"reports\"", | ||
"test": "stryker run", | ||
"posttest": "mocha --no-config --no-package --timeout 0 verify/verify.js", | ||
"test:unit": "NODE_OPTIONS=\"--loader ts-node/esm\" tap --ts" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function add(num1: number, num2: number): number { | ||
return num1 + num2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
export function increment(n: number) { | ||
n++; | ||
return n; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function isNegativeNumber(n: number) { | ||
var isNegative = false; | ||
if (n < 0) { | ||
isNegative = true; | ||
} | ||
return isNegative; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function negate(n: number) { | ||
return -n; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json", | ||
"testRunner": "tap", | ||
"concurrency": 1, | ||
"reporters": ["json", "clear-text", "html", "event-recorder"], | ||
"testRunnerNodeArgs_comment": ["--inspect-brk"], | ||
"tap": { | ||
"nodeArgs": ["--loader", "ts-node/esm"] | ||
}, | ||
"plugins": [ | ||
"@stryker-mutator/tap-runner" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { test } from 'tap'; | ||
import { add } from '../src/add.js'; | ||
|
||
test('add', (t) => { | ||
t.test('should be able to add two numbers', (t) => { | ||
const actual = add(5, 2); | ||
t.equal(actual, 7); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { test } from 'tap'; | ||
import { increment } from '../src/increment.js'; | ||
|
||
test('increment', (t) => { | ||
t.test('should be able to add one to a number', (t) => { | ||
const number = 2; | ||
const expected = 3; | ||
|
||
const actual = increment(number); | ||
|
||
t.equal(actual, expected); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { test } from 'tap'; | ||
import { isNegativeNumber } from '../src/is-negative.js'; | ||
|
||
test('math - should be able to recognize a negative number', (t) => { | ||
const number = -2; | ||
const result = isNegativeNumber(number); | ||
t.equal(result, true); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { test } from 'tap'; | ||
import { negate } from '../src/negate.js'; | ||
|
||
test('negate', (t) => { | ||
t.test('should be able to negate a number', (t) => { | ||
const actual = negate(2); | ||
t.equal(actual, -2); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2022", | ||
"lib": ["es2022"], | ||
"module": "Node16", | ||
"moduleResolution": "node16", | ||
"outDir": "dist", | ||
// "noEmit": true, | ||
"isolatedModules": true, | ||
"verbatimModuleSyntax": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expectMetricsJsonToMatchSnapshot } from '../../../helpers.js'; | ||
|
||
describe('Verify stryker has ran correctly', () => { | ||
it('should report correct score', async () => { | ||
await expectMetricsJsonToMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Verify stryker has ran correctly should report correct score 1`] = ` | ||
Object { | ||
"compileErrors": 0, | ||
"ignored": 0, | ||
"killed": 11, | ||
"mutationScore": 78.57142857142857, | ||
"mutationScoreBasedOnCoveredCode": 78.57142857142857, | ||
"noCoverage": 0, | ||
"pending": 0, | ||
"runtimeErrors": 0, | ||
"survived": 3, | ||
"timeout": 0, | ||
"totalCovered": 14, | ||
"totalDetected": 11, | ||
"totalInvalid": 0, | ||
"totalMutants": 14, | ||
"totalUndetected": 3, | ||
"totalValid": 14, | ||
} | ||
`; |
Oops, something went wrong.