Skip to content

After a failure, TestRunEndReason gets stuck in a failed state. #8062

@esmiralha

Description

@esmiralha

Describe the bug

I'm developing a custom reporter by implementing the onTestRunEnd method of the Reporter interface. After the first test run failure, TestRunEnd Reason is reported as "failed" as expected. But any subsequent successful test run still reports the same "failed" value for TestRunEndReason instead of the expected "passed". The individual TestModules report "passed" in state() as expected.

I'm running in watch mode and using tsx to transpile the tests.

Reproduction

Code for reproduction:

import {
  Reporter,
  TestModule,
  TestRunEndReason,
  SerializedError,
} from "vitest/node";

export default class MyReporter implements Reporter {
  constructor() {
  }

  async onTestRunEnd(
    testModules: ReadonlyArray<TestModule>,
    unhandledErrors: ReadonlyArray<SerializedError>,
    reason: TestRunEndReason
  ): Promise<void> {
    return new Promise<void>((resolve) => {
      console.log("TestRunEndReason: " + reason);
      testModules.forEach((tm, idx) => {
        console.log(`Test Module state ${idx}: ` + tm.state());
      });
      resolve();
    });
  }
}

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.79 GB / 32.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 22.16.0 - ~/.nvm/versions/node/v22.16.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.16.0/bin/npm
    bun: 1.2.6 - ~/.bun/bin/bun
  Browsers:
    Chrome: 137.0.7151.41
    Safari: 18.5
  npmPackages:
    @vitest/coverage-v8: 3.1.4 => 3.1.4 
    vitest: 3.1.4 => 3.1.4

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions