{"record":{"id":"ea8f65f8542e36fc","repo":"vitest-dev/vitest","slug":"no-codec-found-for-type-type","errorCode":null,"errorMessage":"No codec found for type ${type}","messagePattern":"No codec found for type (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser/src/node/commands/screenshotMatcher/codecs/index.ts","lineNumber":11,"sourceCode":"import png from './png'\n\nexport function getCodec(type: 'png'): typeof png\n\nexport function getCodec(type: string) {\n  switch (type) {\n    case 'png':\n      return png\n\n    default:\n      throw new Error(`No codec found for type ${type}`)\n  }\n}\n\nexport type AnyCodec = typeof png\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/browser/src/node/commands/screenshotMatcher/codecs/index.ts#L1-L16","documentation":"Thrown by `getCodec` in the screenshot-matcher codec registry when the requested image type string is not `'png'` (the only built-in codec). The codec encodes/decodes captured screenshot buffers for comparison and reference storage; an unknown type means the matcher cannot process the image, so it aborts. The function is called during option resolution before any capture happens.","triggerScenarios":"Configuring `toMatchScreenshot` options (or a custom screenshot path) with a type other than `'png'`, e.g. `'jpeg'`, `'jpg'`, `'webp'`. Calling `getCodec('jpeg')` directly.","commonSituations":"Passing `screenshotOptions.type: 'jpeg'` to reduce file size; a custom comparator pipeline assuming a format Vitest does not ship; misreading docs that list only PNG as supported.","solutions":["Use `'png'` (the default and only built-in codec).","If you need another format, register a custom codec and pass its name (requires extending the codec registry).","Drop the explicit `type` option so the default PNG codec is used."],"exampleFix":"// before\nexpect(page).toMatchScreenshot({ /* ... */, screenshotOptions: { type: 'jpeg' } })\n\n// after\nexpect(page).toMatchScreenshot({ /* ... */, screenshotOptions: { type: 'png' } })","handlingStrategy":"validation","validationCode":"const SUPPORTED_CODECS = ['png'] as const\nfunction isSupportedCodec(t: string): t is typeof SUPPORTED_CODECS[number] {\n  return (SUPPORTED_CODECS as readonly string[]).includes(t)\n}\nif (!isSupportedCodec(type)) throw new Error(`Unsupported screenshot type: ${type}`)","typeGuard":"function isSupportedCodec(t: string): t is 'png' {\n  return t === 'png'\n}","tryCatchPattern":null,"preventionTips":["Use the default PNG codec; do not set `type` unless you register a custom codec.","Validate the type against supported codecs before configuring.","Remember only PNG ships built-in."],"tags":["screenshot","codec","image-format","browser"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}