@hughescr/stryker-bun-runner 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/index.js +3 -4
- package/dist/templates/coverage-preload.ts +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,17 @@ bunx stryker run
|
|
|
100
100
|
|
|
101
101
|
- **Sequential execution required** - Tests run with `--concurrency=1` to ensure accurate coverage tracking. This is slower than parallel execution but necessary for correct test-to-mutant correlation.
|
|
102
102
|
|
|
103
|
+
## Concurrent Tests
|
|
104
|
+
|
|
105
|
+
This plugin automatically patches `describe.concurrent()`, `test.concurrent()`, and `it.concurrent()` to run sequentially during mutation testing. Your tests will work without modification.
|
|
106
|
+
|
|
107
|
+
**Why?** Coverage tracking requires knowing which test exercised which code. With concurrent execution, the `beforeEach` hook assigns test IDs in the order tests *start*, but coverage is recorded in the order tests *complete*. These orders differ with concurrency, causing coverage to be attributed to the wrong tests.
|
|
108
|
+
|
|
109
|
+
**What this means:**
|
|
110
|
+
- ✅ Your `.concurrent()` tests work automatically with Stryker
|
|
111
|
+
- ✅ Normal test runs (without Stryker) still use concurrent execution
|
|
112
|
+
- ⏱️ Mutation testing runs are slower due to sequential execution
|
|
113
|
+
|
|
103
114
|
## License
|
|
104
115
|
|
|
105
116
|
Apache-2.0
|
package/dist/index.js
CHANGED
|
@@ -2946,7 +2946,6 @@ async function runBunTests(options) {
|
|
|
2946
2946
|
if (options.sequentialMode) {
|
|
2947
2947
|
args.push("--concurrency=1");
|
|
2948
2948
|
}
|
|
2949
|
-
args.push("--no-randomize");
|
|
2950
2949
|
if (options.bunArgs && options.bunArgs.length > 0) {
|
|
2951
2950
|
args.push(...options.bunArgs);
|
|
2952
2951
|
}
|
|
@@ -3766,7 +3765,7 @@ class BunTestRunner {
|
|
|
3766
3765
|
id: fullName,
|
|
3767
3766
|
name: fullName,
|
|
3768
3767
|
fileName: normalizeTestFilePath(testInfo.url),
|
|
3769
|
-
startPosition: undefined,
|
|
3768
|
+
startPosition: testInfo.line !== undefined ? { line: testInfo.line, column: 0 } : undefined,
|
|
3770
3769
|
status: TestStatus.Failed,
|
|
3771
3770
|
failureMessage: parsedTest?.failureMessage ?? testInfo.error?.message ?? "Test failed",
|
|
3772
3771
|
timeSpentMs: elapsed
|
|
@@ -3777,7 +3776,7 @@ class BunTestRunner {
|
|
|
3777
3776
|
id: fullName,
|
|
3778
3777
|
name: fullName,
|
|
3779
3778
|
fileName: normalizeTestFilePath(testInfo.url),
|
|
3780
|
-
startPosition: undefined,
|
|
3779
|
+
startPosition: testInfo.line !== undefined ? { line: testInfo.line, column: 0 } : undefined,
|
|
3781
3780
|
status: TestStatus.Skipped,
|
|
3782
3781
|
timeSpentMs: elapsed
|
|
3783
3782
|
};
|
|
@@ -3786,7 +3785,7 @@ class BunTestRunner {
|
|
|
3786
3785
|
id: fullName,
|
|
3787
3786
|
name: fullName,
|
|
3788
3787
|
fileName: normalizeTestFilePath(testInfo.url),
|
|
3789
|
-
startPosition: undefined,
|
|
3788
|
+
startPosition: testInfo.line !== undefined ? { line: testInfo.line, column: 0 } : undefined,
|
|
3790
3789
|
status: TestStatus.Success,
|
|
3791
3790
|
timeSpentMs: elapsed
|
|
3792
3791
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Note: This is a template file with a placeholder import that gets replaced at runtime
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { beforeEach, afterEach, afterAll } from 'bun:test';
|
|
7
|
+
import { beforeEach, afterEach, afterAll, describe, test, it } from 'bun:test';
|
|
8
8
|
import {
|
|
9
9
|
getPreloadConfig,
|
|
10
10
|
shouldCollectCoverage as shouldCollect,
|
|
@@ -17,6 +17,14 @@ import {
|
|
|
17
17
|
type StrykerNamespace
|
|
18
18
|
} from '__PRELOAD_LOGIC_PATH__';
|
|
19
19
|
|
|
20
|
+
// Patch .concurrent() to be regular sequential execution
|
|
21
|
+
// This ensures accurate coverage tracking during mutation testing
|
|
22
|
+
// Users can still use .concurrent() for faster normal test runs
|
|
23
|
+
// Use Object.defineProperty to override readonly properties
|
|
24
|
+
Object.defineProperty(describe, 'concurrent', { value: describe, writable: true, configurable: true });
|
|
25
|
+
Object.defineProperty(test, 'concurrent', { value: test, writable: true, configurable: true });
|
|
26
|
+
Object.defineProperty(it, 'concurrent', { value: it, writable: true, configurable: true });
|
|
27
|
+
|
|
20
28
|
interface StrykerGlobal {
|
|
21
29
|
[key: string]: unknown
|
|
22
30
|
__stryker__?: StrykerNamespace
|