{"record":{"id":"d79b5f4362efa6fe","repo":"vitest-dev/vitest","slug":"test-runner-doesn-t-support-test-artifacts","errorCode":null,"errorMessage":"Test runner doesn't support test artifacts.","messagePattern":"Test runner doesn't support test artifacts\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/runner/artifact.ts","lineNumber":73,"sourceCode":"\n    if (artifact.type === 'internal:annotation') {\n      artifact.annotation.location = artifact.location\n    }\n  }\n\n  if (Array.isArray(artifact.attachments)) {\n    for (const attachment of artifact.attachments) {\n      manageArtifactAttachment(attachment)\n    }\n  }\n\n  // annotations won't resolve as artifacts for backwards compatibility until next major\n  if (artifact.type === 'internal:annotation') {\n    return artifact\n  }\n\n  if (!runner.onTestArtifactRecord) {\n    throw new Error(`Test runner doesn't support test artifacts.`)\n  }\n\n  await finishSendTasksUpdate(runner)\n\n  const resolvedArtifact = await runner.onTestArtifactRecord(task, artifact)\n\n  task.artifacts.push(resolvedArtifact)\n\n  return resolvedArtifact as typeof artifact\n}\n\nconst table: string[] = []\nfor (let i = 65; i < 91; i++) {\n  table.push(String.fromCharCode(i)) // A-Z\n}\nfor (let i = 97; i < 123; i++) {\n  table.push(String.fromCharCode(i)) // a-z\n}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/runtime/runner/artifact.ts#L55-L91","documentation":"`recordArtifact(task, artifact)` requires the active test runner to implement `onTestArtifactRecord`. If the current runner (obtained via `getRunner()`) does not expose that method (it is undefined), the call throws. This typically means the runner in use predates the artifact API or is a minimal/custom runner that never opted in.","triggerScenarios":"Calling `recordArtifact(task, { type: 'my:artifact', ... })` while running under a runner that does not implement `onTestArtifactRecord` — e.g. a very old built-in runner, a third-party custom runner, or a node-environment runner that was constructed without the artifact reporter wired. The guard is at artifact.ts:72-74.","commonSituations":"Using `recordArtifact` (an `@experimental @advanced` API) with a stale Vitest version where the runner predates artifacts; a custom runner subclass that did not override `onTestArtifactRecord`; calling `recordArtifact` outside a properly initialized runner context (no server-side artifact sink).","solutions":["Upgrade Vitest to a version whose runner implements `onTestArtifactRecord`.","If using a custom runner, override `onTestArtifactRecord(task, artifact)` to persist/forward the artifact.","Guard the call: `if (runner.onTestArtifactRecord) { await recordArtifact(...) }`.","If artifacts are unsupported in your setup, remove the call or gate it behind a feature flag."],"exampleFix":"// before\ncustomRunner = { ...baseRunner } // no onTestArtifactRecord\nawait recordArtifact(task, { type: 'x', passed: true })\n\n// after\ncustomRunner = {\n  ...baseRunner,\n  async onTestArtifactRecord(task, artifact) {\n    // persist and return the resolved artifact\n    return artifact\n  },\n}","handlingStrategy":"type-guard","validationCode":"const runner = getRunner(); if (typeof runner.onTestArtifactRecord !== 'function') throw new Error('runner does not support artifacts; upgrade Vitest or wire the method')","typeGuard":"function supportsArtifacts(runner: any): runner is { onTestArtifactRecord(task: Test, a: TestArtifact): Promise<TestArtifact> } { return typeof runner?.onTestArtifactRecord === 'function' }","tryCatchPattern":"try { await recordArtifact(task, artifact) } catch (e) { if (/doesn't support test artifacts/.test(e.message)) { /* skip or fallback */ return } throw e }","preventionTips":["Upgrade Vitest to a version whose runner implements `onTestArtifactRecord`.","Feature-detect before calling: `if (supportsArtifacts(runner)) await recordArtifact(...)`.","In custom runners, always override `onTestArtifactRecord`."],"tags":["artifacts","runner","api-support","experimental"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}