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
- Treat this as a Vitest internal bug; file an issue with the reproduction and the unexpected state value.
- If using a custom runner, ensure task states are limited to the set the reporter expects (`pass`, `fail`, `skip`, `todo`, `run`, `only`).
- 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
- Treat this as an internal bug and report it with the unexpected state value.
- If building a custom runner, restrict task states to the known set.
- Keep Vitest runner and reporter layers version-aligned.
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
- Task instance was not found for ${runnerTask.type} "${runner
- Task ${id} was not found
- Test specification for task ${id} was not found
- Cannot find iframe with id ${event.iframeId}
- Cannot spawn child server without a parent dev server.
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/f58b0b5ba7235e59.json.
Report an issue: GitHub.