vitest-dev/vitest · error · Error

Unknown suite state: ${state}

Error message

Unknown suite state: ${state}

What it means

Thrown by `getSuiteState` (reported-tasks.ts:801) when a test suite/file task has a `result.state` value that is not one of `skip`, `todo`, `run`, `only`, `fail`, `pass` (and not null/undefined). `getSuiteState` maps each known state to a reported `TestSuiteState`; an unrecognized state means the runner produced a value the reporter layer cannot interpret, which is an internal contract violation rather than a user error.

Source

Thrown at packages/vitest/src/node/reporters/reported-tasks.ts:801

  return reportedTask
}

function getSuiteState(task: RunnerTestSuite | RunnerTestFile): TestSuiteState {
  const mode = task.mode
  const state = task.result?.state
  if (mode === 'skip' || mode === 'todo' || state === 'skip' || state === 'todo') {
    return 'skipped'
  }
  if (state == null || state === 'run' || state === 'only') {
    return 'pending'
  }
  if (state === 'fail') {
    return 'failed'
  }
  if (state === 'pass') {
    return 'passed'
  }
  throw new Error(`Unknown suite state: ${state}`)
}

export function experimental_getRunnerTask(entity: TestCase): RunnerTestCase
export function experimental_getRunnerTask(entity: TestSuite): RunnerTestSuite
export function experimental_getRunnerTask(entity: TestModule): RunnerTestFile
export function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): RunnerTestSuite | RunnerTestFile | RunnerTestCase
export function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): RunnerTestSuite | RunnerTestFile | RunnerTestCase {
  return entity.task
}

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Treat this as a Vitest internal bug; file an issue with the reproduction and the unexpected state value.
  2. If using a custom runner, ensure task states are limited to the set the reporter expects (`pass`, `fail`, `skip`, `todo`, `run`, `only`).
  3. Update Vitest to the latest version where reporter and runner states are aligned.
Defensive patterns

Strategy: try-catch

Type guard

import type { TaskState } from '@vitest/runner'
const KNOWN_STATES = new Set(['pass', 'fail', 'skip', 'todo', 'run', 'only'])
const isKnownState = (s: unknown): s is TaskState => typeof s === 'string' && KNOWN_STATES.has(s)

Try / catch

try {
  // process suite state
} catch (e) {
  if (e instanceof Error && /Unknown suite state/.test(e.message)) {
    // log unexpected state and skip; likely internal bug
  } else throw e
}

Prevention

When it happens

Trigger: A custom runner or fork of Vitest emitting a new state string the reporter doesn't know about; an internal refactor that introduces a new state without updating `getSuiteState`; corrupted/in-flight task state observed mid-transition.

Common situations: Running an experimental Vitest version with reporter incompatibilities; third-party runner plugins that assign custom state strings to tasks.

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/f58b0b5ba7235e59.json. Report an issue: GitHub.