{"id":"f58b0b5ba7235e59","repo":"vitest-dev/vitest","slug":"unknown-suite-state-state","errorCode":null,"errorMessage":"Unknown suite state: ${state}","messagePattern":"Unknown suite state: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/reporters/reported-tasks.ts","lineNumber":801,"sourceCode":"  return reportedTask\n}\n\nfunction getSuiteState(task: RunnerTestSuite | RunnerTestFile): TestSuiteState {\n  const mode = task.mode\n  const state = task.result?.state\n  if (mode === 'skip' || mode === 'todo' || state === 'skip' || state === 'todo') {\n    return 'skipped'\n  }\n  if (state == null || state === 'run' || state === 'only') {\n    return 'pending'\n  }\n  if (state === 'fail') {\n    return 'failed'\n  }\n  if (state === 'pass') {\n    return 'passed'\n  }\n  throw new Error(`Unknown suite state: ${state}`)\n}\n\nexport function experimental_getRunnerTask(entity: TestCase): RunnerTestCase\nexport function experimental_getRunnerTask(entity: TestSuite): RunnerTestSuite\nexport function experimental_getRunnerTask(entity: TestModule): RunnerTestFile\nexport function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): RunnerTestSuite | RunnerTestFile | RunnerTestCase\nexport function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): RunnerTestSuite | RunnerTestFile | RunnerTestCase {\n  return entity.task\n}\n","sourceCodeStart":783,"sourceCodeEnd":811,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/reporters/reported-tasks.ts#L783-L811","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running an experimental Vitest version with reporter incompatibilities; third-party runner plugins that assign custom state strings to tasks.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import type { TaskState } from '@vitest/runner'\nconst KNOWN_STATES = new Set(['pass', 'fail', 'skip', 'todo', 'run', 'only'])\nconst isKnownState = (s: unknown): s is TaskState => typeof s === 'string' && KNOWN_STATES.has(s)","tryCatchPattern":"try {\n  // process suite state\n} catch (e) {\n  if (e instanceof Error && /Unknown suite state/.test(e.message)) {\n    // log unexpected state and skip; likely internal bug\n  } else throw e\n}","preventionTips":["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."],"tags":["reporter","internal","tasks","invariant"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}