No tests were found
🐛 Bug
**Summary**
I have been trying to use stryker with angular for several years now. I'm trying again, now and then, without success.
My current problem is the following
```shell
npx stryker run
19:20:52 (2804) WARN ProjectReader Glob pattern "!src/test.ts" did not exclude any files.
19:20:52 (2804) WARN ProjectReader Glob pattern "!src/environments/*.ts" did not exclude any files.
19:20:52 (2804) INFO ProjectReader Found 4 of 204 file(s) to be mutated.
19:20:52 (2804) INFO Instrumenter Instrumented 4 source file(s) with 7 mutant(s)
19:20:53 (2804) INFO ConcurrencyTokenProvider Creating 19 test runner process(es).
19:20:55 (2804) INFO DryRunExecutor Starting initial test run (vitest test runner with "perTest" coverage analysis). This may take a while.
19:20:56 (23568) WARN VitestTestRunner Vitest failed to find test files related to mutated files. Either disable `vitest.related` or import your source files directly from your test files. See https://stryker-mutator.io/docs/stryker-js/troubleshooting/#vitest-failed-to-find-test-files-related-to-mutated-files
19:20:56 (2804) INFO DryRunExecutor No tests were found
19:20:56 (2804) ERROR Stryker No tests were executed. Stryker will exit prematurely. Please check your configuration.
```
I'm now on fresh angular 21 with everything to default.
Can anyone show me any working configuration with that or a clue to understand how to overcome this problem?
Either disable vitest.related => this does not work
or import your source files directly from your test files. => that I do not understand, the file is always imported in the test, no?
```typescript
import { TestBed } from '@angular/core/testing';
import { App } from './app';
describe('App', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [App],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(App);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
});
```
**Stryker config**
```json
{
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"packageManager": "npm",
"reporters": [
"html",
"clear-text",
"progress"
],
"mutate": [
"src/**/*.ts",
"!src/**/*.spec.ts",
"!src/test.ts",
"!src/environments/*.ts"
],
"testRunner": "vitest",
"coverageAnalysis": "perTest"
}
```
**package.json**
```json
{
"name": "starter-angular-vite-vitest",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular"
}
}
]
},
"private": true,
"packageManager": "npm@10.9.2",
"dependencies": {
"@angular/common": "^21.1.0",
"@angular/compiler": "^21.1.0",
"@angular/core": "^21.1.0",
"@angular/forms": "^21.1.0",
"@angular/platform-browser": "^21.1.0",
"@angular/router": "^21.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@analogjs/vite-plugin-angular": "^2.2.3",
"@angular/build": "^21.1.4",
"@angular/cli": "^21.1.4",
"@angular/compiler-cli": "^21.1.0",
"@stryker-mutator/core": "^9.5.1",
"@stryker-mutator/vitest-runner": "^9.5.1",
"jsdom": "^27.1.0",
"typescript": "~5.9.2",
"vitest": "^4.0.8"
}
}
```
**Your Environment**
| software | version(s)
| ---------------- | -------
| node | 22.12
| npm | 11.10
| Operating System | Windows 11
**Add stryker.log**
```
starter-angular-vite-vitest/node_modules/@stryker-mutator/core/dist/src/process/3-dry-run-executor.js:47
throw new ConfigError('No tests were executed. Stryker will exit prematurely. Please check your configuration.');
^
ConfigError: No tests were executed. Stryker will exit prematurely. Please check your configuration.
at DryRunExecutor.execute (file:///C:/Users/thoma/projects/perso/tests_sandbox/starter-angular-vite-vitest/node_modules/@stryker-mutator/core/dist/src/process/3-dry-run-executor.js:47:19)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Stryker.run (file:///C:/Users/thoma/projects/perso/tests_sandbox/starter-angular-vite-vitest/node_modules/@stryker-mutator/core/dist/src/stryker.js:52:53)
at async Stryker.runMutationTest (file:///C:/Users/thoma/projects/perso/tests_sandbox/starter-angular-vite-vitest/node_modules/@stryker-mutator/core/dist/src/stryker.js:27:20)
at async Command.<anonymous> (file:///C:/Users/thoma/projects/perso/tests_sandbox/starter-angular-vite-vitest/node_modules/@stryker-mutator/core/dist/src/stryker-cli.js:43:13) {
innerError: undefined
}
Node.js v22.12.0
```
Thanks in advance for any tip!
6 条评论