-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vitest): support vitest test runner
Add support for [vitest](vitest.dev) as a test runner using the `@stryker-mutator/vitest-runner` plugin. This plugin currently supports minimal options: ```json { "testRunner": "vitest", "vitest": { "configFile": "vitest.config.js" } } ``` Limitations: - The vitest runner only supports `"coverageAnalysis": "perTest"`. - Some vitest options are always overridden by the plugin: - `threads: true`, `coverage: { enabled: false }`, `singleThread: true` --------- Co-authored-by: Nico Jansen <jansennico@gmail.com> Co-authored-by: danny12321 <dannyberkelaar@gmail.com>
- Loading branch information
1 parent
6e53201
commit 7394e95
Showing
98 changed files
with
7,093 additions
and
42 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,15 @@ | ||
{ | ||
"name": "vitest-noconfig", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "A module to perform an integration test", | ||
"main": "index.js", | ||
"scripts": { | ||
"pretest": "rimraf \"reports\"", | ||
"test": "stryker run", | ||
"posttest": "mocha --no-config --no-package --timeout 0 verify/verify.js", | ||
"test:unit": "vitest run" | ||
}, | ||
"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) { | ||
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(number: number) { | ||
number++; | ||
return number; | ||
} | ||
|
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(number: number) { | ||
var isNegative = false; | ||
if (number < 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,4 @@ | ||
|
||
export function negate(number: number) { | ||
return -number; | ||
} |
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,10 @@ | ||
{ | ||
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json", | ||
"testRunner": "vitest", | ||
"concurrency": 1, | ||
"coverageAnalysis": "perTest", | ||
"reporters": ["json", "clear-text", "html", "event-recorder"], | ||
"plugins": [ | ||
"@stryker-mutator/vitest-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,9 @@ | ||
import { add } from '../src/add'; | ||
import { expect, test, describe } from 'vitest'; | ||
|
||
describe('add', () => { | ||
test('should be able to add two numbers', function () { | ||
const actual = add(5, 2); | ||
expect(actual).toBe(7); | ||
}); | ||
}); |
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,15 @@ | ||
import { increment } from '../src/increment'; | ||
import { expect, test, describe } from 'vitest'; | ||
|
||
describe('increment', () => { | ||
|
||
test('should be able to add one to a number', function () { | ||
var number = 2; | ||
var expected = 3; | ||
|
||
var actual = increment(number); | ||
|
||
expect(actual).toBe(expected); | ||
}); | ||
|
||
}); |
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,11 @@ | ||
import { isNegativeNumber } from '../src/is-negative'; | ||
import { expect, test, describe } from 'vitest'; | ||
|
||
describe('math', () => { | ||
|
||
test('should be able to recognize a negative number', function () { | ||
const number = -2; | ||
const result = isNegativeNumber(number); | ||
expect(result).toBe(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,9 @@ | ||
import { negate } from '../src/negate'; | ||
import { expect, test, describe } from 'vitest'; | ||
|
||
describe('negate', () => { | ||
test('should be able negate a number', function () { | ||
const actual = negate(2); | ||
expect(actual).toBe(-2); | ||
}); | ||
}); |
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 @@ | ||
{ | ||
"type": "module" | ||
} |
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.