vitest-dev/vitest · error · Error
Test runner doesn't support test annotations.
Error message
Test runner doesn't support test annotations.
What it means
Calling `context.annotate()` requires the active test runner to implement `runner.onTestAnnotate` (context.ts:210-211). This is checked at annotation time. If the runner in use (e.g. a custom or minimal runner) does not provide this callback, annotations are unsupported and the error is thrown after the annotation artifact is recorded.
Source
Thrown at packages/vitest/src/runtime/runner/context.ts:211
}
const annotation: TestAnnotation = {
message,
type: typeof type === 'object' || type === undefined ? 'notice' : type,
}
const annotationAttachment = typeof type === 'object' ? type : attachment
if (annotationAttachment) {
annotation.attachment = annotationAttachment
manageArtifactAttachment(annotation.attachment)
}
return recordAsyncOperation(
test,
recordArtifact(test, { type: 'internal:annotation', annotation }).then(async ({ annotation }) => {
if (!runner.onTestAnnotate) {
throw new Error(`Test runner doesn't support test annotations.`)
}
await finishSendTasksUpdate(runner)
const resolvedAnnotation = await runner.onTestAnnotate(test, annotation)
test.annotations.push(resolvedAnnotation)
return resolvedAnnotation
}),
)
}) as TestContext['annotate']
context.onTestFailed = (handler, timeout) => {
test.onFailed ||= []
test.onFailed.push(
withTimeout(
handler,
timeout ?? runner.config.hookTimeout,
true,View on GitHub (pinned to d568f8ce37)
Solutions
- Implement `onTestAnnotate` on your custom `VitestRunner` subclass.
- Use the built-in Vitest runners (e.g. the default test runner) which support annotations.
- Avoid calling `annotate()` when running under a runner known to lack annotation support.
Example fix
// before: custom runner without onTestAnnotate
class MyRunner extends VitestRunner {
// ... no onTestAnnotate
}
// after
class MyRunner extends VitestRunner {
onTestAnnotate(test, annotation) {
// forward annotation to reporter/store
return annotation
}
} Defensive patterns
Strategy: type-guard
Validate before calling
function runnerSupportsAnnotations(runner: unknown): runner is { onTestAnnotate: Function } {
return typeof (runner as any)?.onTestAnnotate === 'function'
}
if (runnerSupportsAnnotations(getRunner())) {
context.annotate('note')
} Type guard
function runnerSupportsAnnotations(runner: unknown): runner is { onTestAnnotate: Function } {
return typeof (runner as any)?.onTestAnnotate === 'function'
} Try / catch
try {
await context.annotate('note')
} catch (e) {
if (e instanceof Error && /doesn't support test annotations/.test(e.message)) {
// annotations unsupported in this runner; degrade gracefully
} else throw e
} Prevention
- If you ship a custom runner, implement onTestAnnotate explicitly.
- Feature-detect annotation support before relying on it in shared helpers.
When it happens
Trigger: Using a custom `VitestRunner` that does not define `onTestAnnotate`; calling `context.annotate()` under a runner profile (e.g. some browser or benchmark contexts) that omits annotation support.
Common situations: Building a custom runner for specialized environments; using Vitest APIs under a reduced-capability runner; upgrading Vitest and using annotate with an older custom runner.
Related errors
- Runner ${task.worker} is not supported. Test files: ${format
- Cannot annotate tests outside of the test run. The test "${t
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/ddb02d47e6ee34a1.json.
Report an issue: GitHub.