WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

[email protected] html reporter throws exception #9190

@dezsiszabi

Description

@dezsiszabi

Describe the bug

package.json

{
  "name": "vitest_project",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "test": "vitest"
  },
  "devDependencies": {
    "@vitest/browser-playwright": "4.0.15",
    "@vitest/ui": "4.0.15",
    "vitest": "4.0.15"
  }
}

vitest.config.js

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',
                headless: true
            }
        ]
    },
    reporters: [
        'html'
    ],
    include: ['tests/**/*.test.{js,mjs,cjs,ts}']
  }
});

tests/example.test.js

import { describe, it, expect } from 'vitest';

describe('basic', () => {
  it('1 equals 1', () => {
    expect(1).toBe(1);
  });
});

When running npm test I get the following error

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: Cannot find environment for /home/dezsiszabi/projects/vitest_project/tests/example.test.js
 ❯ 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

[email protected] works fine.

First noticed while using vitest with angular and reported here (angular/angular-cli#32054), but I can reproduce this issue outside Angular so it seems like a vitest issue.

Reproduction

See description.

System Info

System:
    OS: Linux 5.15 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 12.69 GB / 15.58 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.11.1 - /usr/bin/node
    Yarn: 1.22.22 - /mnt/c/Users/dezsi/AppData/Roaming/npm/yarn
    npm: 11.6.2 - /usr/bin/npm
    pnpm: 10.24.0 - /mnt/c/Users/dezsi/AppData/Roaming/npm/pnpm
  npmPackages:
    @vitest/browser-playwright: 4.0.15 => 4.0.15 
    @vitest/ui: 4.0.15 => 4.0.15 
    vitest: 4.0.15 => 4.0.15

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions