@hughescr/stryker-bun-runner 1.0.0 → 1.1.0
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/dist/index.js +4 -17
- package/dist/templates/coverage-preload.ts +6 -30
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -3188,9 +3188,10 @@ async function generatePreloadScript(options) {
|
|
|
3188
3188
|
const preloadPath = join(options.tempDir, "stryker-coverage-preload.ts");
|
|
3189
3189
|
await mkdir(options.tempDir, { recursive: true });
|
|
3190
3190
|
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
3191
|
-
const
|
|
3191
|
+
const isBundled = __dirname2.endsWith("dist") || __dirname2.includes("dist/");
|
|
3192
|
+
const templatePath = isBundled ? join(__dirname2, "templates/coverage-preload.ts") : join(__dirname2, "../templates/coverage-preload.ts");
|
|
3192
3193
|
const template = await readFile(templatePath, "utf-8");
|
|
3193
|
-
const preloadLogicPath = join(__dirname2, "coverage/preload-logic.js");
|
|
3194
|
+
const preloadLogicPath = isBundled ? join(__dirname2, "coverage/preload-logic.js") : join(__dirname2, "preload-logic.ts");
|
|
3194
3195
|
const content = template.replace("__PRELOAD_LOGIC_PATH__", preloadLogicPath);
|
|
3195
3196
|
await writeFile(preloadPath, content, "utf-8");
|
|
3196
3197
|
return preloadPath;
|
|
@@ -3631,16 +3632,6 @@ class SyncServer {
|
|
|
3631
3632
|
} catch {}
|
|
3632
3633
|
}
|
|
3633
3634
|
}
|
|
3634
|
-
sendTestStart(testName) {
|
|
3635
|
-
const message = JSON.stringify({ type: "testStart", name: testName });
|
|
3636
|
-
for (const client of this.clients) {
|
|
3637
|
-
try {
|
|
3638
|
-
if (client.readyState === this.webSocketOpenState) {
|
|
3639
|
-
client.send(message);
|
|
3640
|
-
}
|
|
3641
|
-
} catch {}
|
|
3642
|
-
}
|
|
3643
|
-
}
|
|
3644
3635
|
async close() {
|
|
3645
3636
|
for (const client of this.clients) {
|
|
3646
3637
|
try {
|
|
@@ -3852,11 +3843,7 @@ class BunTestRunner {
|
|
|
3852
3843
|
url: inspectorUrl,
|
|
3853
3844
|
connectionTimeout: this.inspectorTimeout,
|
|
3854
3845
|
requestTimeout: this.inspectorTimeout,
|
|
3855
|
-
handlers: {
|
|
3856
|
-
onTestStart: (test) => {
|
|
3857
|
-
syncServer.sendTestStart(test.fullName);
|
|
3858
|
-
}
|
|
3859
|
-
}
|
|
3846
|
+
handlers: {}
|
|
3860
3847
|
});
|
|
3861
3848
|
try {
|
|
3862
3849
|
await inspector.connect();
|
|
@@ -41,14 +41,9 @@ const shouldCollectCoverage = shouldCollect(config);
|
|
|
41
41
|
// ============================================================================
|
|
42
42
|
let ws: WebSocket | null = null;
|
|
43
43
|
|
|
44
|
-
// Track test counter
|
|
44
|
+
// Track test counter (only needed when collecting coverage)
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call -- Placeholder import replaced at runtime
|
|
46
46
|
const testCounter = createTestCounter();
|
|
47
|
-
let pendingTestName: string | undefined;
|
|
48
|
-
|
|
49
|
-
if(shouldCollectCoverage) {
|
|
50
|
-
// Coverage collection will use these variables
|
|
51
|
-
}
|
|
52
47
|
|
|
53
48
|
if(syncPort && shouldCollectCoverage) {
|
|
54
49
|
try {
|
|
@@ -63,13 +58,6 @@ if(syncPort && shouldCollectCoverage) {
|
|
|
63
58
|
// Initial ready signal - tests can start
|
|
64
59
|
return;
|
|
65
60
|
}
|
|
66
|
-
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Parsed message has dynamic type
|
|
68
|
-
if(parsedMessage && typeof parsedMessage === 'object' && parsedMessage.type === 'testStart') {
|
|
69
|
-
// Store the pending test name to be picked up by beforeEach
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access -- Parsed message has dynamic type
|
|
71
|
-
pendingTestName = parsedMessage.name;
|
|
72
|
-
}
|
|
73
61
|
};
|
|
74
62
|
|
|
75
63
|
// Wait for ready signal
|
|
@@ -179,23 +167,11 @@ if(shouldCollectCoverage) {
|
|
|
179
167
|
beforeEach(() => {
|
|
180
168
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access -- TestCounter from placeholder import
|
|
181
169
|
const counterId = testCounter.increment();
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- StrykerGlobal from placeholder import
|
|
188
|
-
strykerGlobal.currentTestId = pendingTestName;
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- MutantCoverage from placeholder import
|
|
190
|
-
mutantCoverage.perTest[pendingTestName] ??= {};
|
|
191
|
-
pendingTestName = undefined;
|
|
192
|
-
} else {
|
|
193
|
-
// Fallback to counter - will be remapped later
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access -- StrykerGlobal from placeholder import
|
|
195
|
-
strykerGlobal.currentTestId = counterId;
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- MutantCoverage from placeholder import
|
|
197
|
-
mutantCoverage.perTest[counterId] ??= {};
|
|
198
|
-
}
|
|
170
|
+
// Always use counter-based IDs - coverage-mapper remaps to full names using inspector data
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access -- StrykerGlobal from placeholder import
|
|
172
|
+
strykerGlobal.currentTestId = counterId;
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- MutantCoverage from placeholder import
|
|
174
|
+
mutantCoverage.perTest[counterId] ??= {};
|
|
199
175
|
});
|
|
200
176
|
|
|
201
177
|
afterEach(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hughescr/stryker-bun-runner",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Stryker test runner plugin for Bun with perTest coverage support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stryker",
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
"mutate": "stryker run",
|
|
38
38
|
"prepublishOnly": "bun run build",
|
|
39
39
|
"test": "bun test",
|
|
40
|
-
"typecheck": "tsc --noEmit"
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"postversion": "git commit -m \"Bump package version to $npm_package_version\" package.json; git flow release start $npm_package_version; git flow release finish -m $npm_package_version $npm_package_version; git checkout develop; git merge main"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@stryker-mutator/api": "9.
|
|
44
|
+
"@stryker-mutator/api": "9.5.1",
|
|
44
45
|
"ws": "8.19.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@hughescr/eslint-config-default": "4.0.1",
|
|
48
|
-
"@stryker-mutator/core": "9.
|
|
49
|
-
"@stryker-mutator/typescript-checker": "9.
|
|
50
|
-
"@types/bun": "1.3.
|
|
51
|
-
"@types/node": "25.0
|
|
49
|
+
"@stryker-mutator/core": "9.5.1",
|
|
50
|
+
"@stryker-mutator/typescript-checker": "9.5.1",
|
|
51
|
+
"@types/bun": "1.3.8",
|
|
52
|
+
"@types/node": "25.2.0",
|
|
52
53
|
"@types/ws": "8.18.1",
|
|
53
54
|
"dts-bundle-generator": "9.5.1",
|
|
54
55
|
"eslint": "9.39.2",
|
|
55
56
|
"eslint-formatter-overview": "2.0.0",
|
|
56
57
|
"eslint-formatter-unix": "9.0.1",
|
|
57
|
-
"eslint-plugin-package-json": "0.88.1",
|
|
58
58
|
"typescript": "5.9.3"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|