Crash when using Vite + dynamic imports
🐛 Bug
**Summary**
Stryker applies the `FilledStringToEmpty` mutator on all strings, including dynamic imports, for example this:
```ts
const { deleteBoardsPermanentlyUnchecked } = await import("$lib/services/board/manage.server")
```
becomes this:
```ts
const { deleteBoardsPermanentlyUnchecked } = await import(stryMutAct_9fa48("2680") ? "" : (stryCov_9fa48("2680"), "$lib/services/board/manage.server"));
```
Which then causes Vite pipeline to try and process the 2 imports: `"$lib/services/board/manage.server"` and `""`. The latter resolves to the project root directory and fails to load since it's a directory, not file, with:
```
18:30:49 (33824) ERROR DryRunExecutor One or more tests resulted in an error:
Test runner crashed. Tried twice to restart it without any luck. Last time the error message was: Error: Error: ERR_LOAD_URL (undefined) Error: Failed to load url C:/Users/Matei/<project-dir>/.stryker-tmp/sandbox-wOVtDp (resolved id: C:/Users/Matei/<project-dir>/.stryker-tmp/sandbox-wOVtDp). Does the file exist?
```
**Stryker config**
<!--- Please place your stryker config below. Feel free to change paths in the files and mutate arrays if you cannot share them. -->
```js
// https://stryker-mutator.io/docs/stryker-js/guides/svelte
// @ts-check
/** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */
const config = {
packageManager: "yarn",
testRunner: "vitest",
reporters: ["progress", "clear-text", "html"],
mutate: [
"src/**/*.ts",
"!src/**/*.d.ts",
"!src/**/*.test.ts",
],
ignorePatterns: [".idea", ".github", "build", "mod_packages", "scripts", "static", ".env", ".env.*", "*.MD"],
}
// noinspection JSUnusedGlobalSymbols
export default config
```
**Stryker environment**
<!-- Please list your stryker plugins + versions here (output of `npm ls | grep stryker` or `npm ls | findstr "stryker"` on Windows) -->
```
+-- @stryker-mutator/api@9.4.0
+-- @stryker-mutator/core@9.4.0
+-- @stryker-mutator/instrumenter@9.4.0
+-- @stryker-mutator/util@9.4.0
+-- @stryker-mutator/vitest-runner@9.4.0
```
<!-- Please also add the test runner you are using. Examples:-->
```
+-- vite@7.3.1
+-- vitest@4.0.17
```
**Test runner environment**
<!-- Please add your test command here (probably the command you use in `npm test`) command -->
```shell
vitest
stryker run
```
**Your Environment**
| software | version(s)
| ---------------- | -------
| node | v24.4.0
| yarn | v4.12.0
| Operating System | Window 11 [Version 10.0.26100.7623]
**Add stryker.log**
[stryker.log](https://github.com/user-attachments/files/24970436/stryker.log)
关闭于 2026-02-27 2 条评论