Skip to content

Exception when using html reporter with vitest@4.0.15 #32054

@dezsiszabi

Description

@dezsiszabi

Command

test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When using the latest of the following packages:

  • vitest@4.0.15
  • @vitest/browser-playwrigh@4.0.15
  • @vitest/ui@4.0.15

And the following configurations

angular.json:

"test": {
  "builder": "@angular/build:unit-test",
  "options": {
    "runnerConfig": "vitest.config.ts"
  }
}

vitest.config.ts

import { defineConfig } from 'vitest/config'
import { playwright } from '@vitest/browser-playwright';

export default defineConfig({
  test: {
    browser: {
      enabled: true,
      headless: true,
      provider: playwright(),
      instances: [
        {
          browser: 'chromium'
        }
      ],
    },
    reporters: [
      ['html']
    ]
  },
});

The npm run test command fails with the following:

Error: Cannot find environment for /home/dezsiszabi/projects/angular21project/src/app/app.spec.ts
 ❯ getModuleGraph node_modules/@vitest/ui/dist/reporter.js:487:9
 ❯ node_modules/@vitest/ui/dist/reporter.js:594:59
 ❯ HTMLReporter.onTestRunEnd node_modules/@vitest/ui/dist/reporter.js:588:35
 ❯ node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:12876:56
 ❯ Vitest.report node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:12876:36
 ❯ TestRun.end node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:11716:21
 ❯ node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:12529:26
 ❯ node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:12539:11

The project is just a simple ng new using the latest Angular version.

vitest@4.0.14 works fine.

Minimal Reproduction

See description.

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 21.0.2
Angular           : 21.0.3
Node.js           : 24.11.1
Package Manager   : npm 11.6.2
Operating System  : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.0.2            │ ^21.0.2           │
│ @angular/cli              │ 21.0.2            │ ^21.0.2           │
│ @angular/common           │ 21.0.3            │ ^21.0.3           │
│ @angular/compiler         │ 21.0.3            │ ^21.0.3           │
│ @angular/compiler-cli     │ 21.0.3            │ ^21.0.3           │
│ @angular/core             │ 21.0.3            │ ^21.0.3           │
│ @angular/forms            │ 21.0.3            │ ^21.0.3           │
│ @angular/platform-browser │ 21.0.3            │ ^21.0.3           │
│ @angular/router           │ 21.0.3            │ ^21.0.3           │
│ rxjs                      │ 7.8.2             │ ~7.8.2            │
│ typescript                │ 5.9.3             │ ~5.9.3            │
│ vitest                    │ 4.0.15            │ 4.0.15            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

Possibly a bug in vitest (?) in which case I can open the issue in their repo. UPDATE: I opened an issue in vitest repo as well: vitest-dev/vitest#9190

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions