{"id":"ddb02d47e6ee34a1","repo":"vitest-dev/vitest","slug":"test-runner-doesn-t-support-test-annotations","errorCode":null,"errorMessage":"Test runner doesn't support test annotations.","messagePattern":"Test runner doesn't support test annotations\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/runner/context.ts","lineNumber":211,"sourceCode":"    }\n\n    const annotation: TestAnnotation = {\n      message,\n      type: typeof type === 'object' || type === undefined ? 'notice' : type,\n    }\n    const annotationAttachment = typeof type === 'object' ? type : attachment\n\n    if (annotationAttachment) {\n      annotation.attachment = annotationAttachment\n\n      manageArtifactAttachment(annotation.attachment)\n    }\n\n    return recordAsyncOperation(\n      test,\n      recordArtifact(test, { type: 'internal:annotation', annotation }).then(async ({ annotation }) => {\n        if (!runner.onTestAnnotate) {\n          throw new Error(`Test runner doesn't support test annotations.`)\n        }\n\n        await finishSendTasksUpdate(runner)\n\n        const resolvedAnnotation = await runner.onTestAnnotate(test, annotation)\n        test.annotations.push(resolvedAnnotation)\n        return resolvedAnnotation\n      }),\n    )\n  }) as TestContext['annotate']\n\n  context.onTestFailed = (handler, timeout) => {\n    test.onFailed ||= []\n    test.onFailed.push(\n      withTimeout(\n        handler,\n        timeout ?? runner.config.hookTimeout,\n        true,","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/runtime/runner/context.ts#L193-L229","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: custom runner without onTestAnnotate\nclass MyRunner extends VitestRunner {\n  // ... no onTestAnnotate\n}\n// after\nclass MyRunner extends VitestRunner {\n  onTestAnnotate(test, annotation) {\n    // forward annotation to reporter/store\n    return annotation\n  }\n}","handlingStrategy":"type-guard","validationCode":"function runnerSupportsAnnotations(runner: unknown): runner is { onTestAnnotate: Function } {\n  return typeof (runner as any)?.onTestAnnotate === 'function'\n}\nif (runnerSupportsAnnotations(getRunner())) {\n  context.annotate('note')\n}","typeGuard":"function runnerSupportsAnnotations(runner: unknown): runner is { onTestAnnotate: Function } {\n  return typeof (runner as any)?.onTestAnnotate === 'function'\n}","tryCatchPattern":"try {\n  await context.annotate('note')\n} catch (e) {\n  if (e instanceof Error && /doesn't support test annotations/.test(e.message)) {\n    // annotations unsupported in this runner; degrade gracefully\n  } else throw e\n}","preventionTips":["If you ship a custom runner, implement onTestAnnotate explicitly.","Feature-detect annotation support before relying on it in shared helpers."],"tags":["annotation","custom-runner","runner-capability"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}