Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VITEST_FILES_NOT_FOUND error when running Stryker with Angular 18 and Vitest #5119

Open
cquilezg opened this issue Nov 15, 2024 · 0 comments
Labels
🐛 Bug Something isn't working

Comments

@cquilezg
Copy link

Summary

I've added Vitest to my project, which uses Angular 18 and TypeScript. The tests run successfully with Vitest. However, when I try to run Stryker (using the Vitest runner extension), I encounter the following error:
15:45:22 (15888) 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: VITEST_FILES_NOT_FOUND (undefined) Error: No test files found at Vitest.start (file:///C:/projects/github/angular18-vitest-stryker/node_modules/vitest/dist/chunks/cli-api.btGgw3PC.js:10518:15) at async VitestTestRunner.run (file:///C:/projects/github/angular18-vitest-stryker/node_modules/@stryker-mutator/vitest-runner/dist/src/vitest-test-runner.js:94:13) at async VitestTestRunner.dryRun (file:///C:/projects/github/angular18-vitest-stryker/node_modules/@stryker-mutator/vitest-runner/dist/src/vitest-test-runner.js:58:28) at async ChildProcessTestRunnerWorker.dryRun (file:///C:/projects/github/angular18-vitest-stryker/node_modules/@stryker-mutator/core/dist/src/test-runner/child-process-test-runner-worker.js:25:30)

Here the complete stryker.log for the command npx stryker run --fileLogLevel trace.

What I've Tried

  • Tested in my real project with Angular 17 and with a new project also with Angular 17 -> same error.
  • Confirmed that tests run correctly using vitest.
  • Reviewed the Stryker documentation to ensure the configuration is accurate: https://stryker-mutator.io/docs/stryker-js/guides/angular/ and https://stryker-mutator.io/docs/stryker-js/vitest-runner/ .
  • Debugged Stryker in VS Code adding this configuration to .vscode/launch.json:
    { "type": "node", "request": "launch", "name": "Debug Stryker", "skipFiles": ["<node_internals>/**"], "program": "${workspaceFolder}/node_modules/@stryker-mutator/core/bin/stryker", "args": ["run"], "console": "integratedTerminal", "outputCapture": "std" }

What I've seen when debugging is that in @stryker-mutator/core/dist/src/test-runner/child-process-test-runner-worker.js is invoking the corresponding testing runner with dryRun(options),
image
but vitest-test-runner.js is not accepting arguments.
image

Idk if this could be related with the problem.

Any Ideas for a Solution?
I would greatly appreciate any guidance or suggestions on how to resolve this issue.

I've uploaded the project here: angular18-vitest-stryker

Steps to Reproduce

  • Create a new Angular 18 project with TypeScript.
  • Set up Vitest as the testing framework.
  • Ensure tests run correctly by executing vitest.
  • Add Stryker and configure it to use the Vitest runner.
  • Run Stryker with the following command:
    npx stryker run

Relevant Configuration

Angular: 18.2.0
TypeScript: 5.5.2
Vitest: 2.1.3
Stryker: 8.6.0

Stryker config

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "packageManager": "npm",
  "reporters": ["html", "clear-text", "progress"],
  "testRunner": "vitest",
  "vitest": {
    "configFile": "vite.config.ts",
    "dir": "src"
  },
  "tsconfigFile": "tsconfig.json",
  "mutate": [
    "src/**/*.ts",
    "!src/**/*.spec.ts",
    "!src/main.ts",
    "!src/test-setup.ts",
    "!src/app/app.config.ts",
    "!src/environments/*.ts"
   ],
  "timeoutMS": 30000,
  "thresholds": {
    "high": 100,
    "low": 85,
    "break": 80
  },
  "incremental": true
 }

Test runner config

vite.config.ts

/// <reference types="vitest" />
import { defineConfig } from 'vite';

import angular from '@analogjs/vite-plugin-angular';

export default defineConfig(({ mode }) => ({
  plugins: [angular()],
  test: {
    globals: true,
    setupFiles: ['src/test-setup.ts'],
    environment: 'jsdom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
    reporters: ['default'],
  },
  define: {
    'import.meta.vitest': mode !== 'production',
  },
}));

Stryker environment
Stryker dependencies:

+-- @stryker-mutator/[email protected]
+-- @stryker-mutator/[email protected]
+-- @stryker-mutator/[email protected]

Test runner dependencies:

+-- [email protected]
+-- @analogjs/[email protected]
+-- @analogjs/[email protected]
+-- @vitest/[email protected]

Test runner environment

# Test command
npx stryker run

src/test-setup.ts

import '@analogjs/vitest-angular/setup-snapshots';

import {
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
import { getTestBed } from '@angular/core/testing';

getTestBed().initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting()
);

Your Environment

software version(s)
node 22.11.0
npm 10.9.0
Operating System Windows 10

Thank you in advance!

@cquilezg cquilezg added the 🐛 Bug Something isn't working label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant