{"id":"f0d40956478f91dd","repo":"vitest-dev/vitest","slug":"pretty-format-unknown-option-key","errorCode":null,"errorMessage":"pretty-format: Unknown option \"${key}\".","messagePattern":"pretty-format: Unknown option \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/pretty-format/src/index.ts","lineNumber":471,"sourceCode":"  // (Node's limit is buffer.constants.MAX_STRING_LENGTH ~ 512MB)\n  maxOutputLength: 1_000_000,\n  maxWidth: Number.POSITIVE_INFINITY,\n  min: false,\n  plugins: [],\n  printBasicPrototype: true,\n  printFunctionName: true,\n  printShadowRoot: true,\n  theme: DEFAULT_THEME,\n  singleQuote: false,\n  quoteKeys: true,\n  spacingInner: '\\n',\n  spacingOuter: '\\n',\n} satisfies Options\n\nfunction validateOptions(options: OptionsReceived) {\n  for (const key of Object.keys(options)) {\n    if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {\n      throw new Error(`pretty-format: Unknown option \"${key}\".`)\n    }\n  }\n\n  if (options.min && options.indent !== undefined && options.indent !== 0) {\n    throw new Error(\n      'pretty-format: Options \"min\" and \"indent\" cannot be used together.',\n    )\n  }\n}\n\nfunction getColorsHighlight(): Colors {\n  return DEFAULT_THEME_KEYS.reduce((colors, key) => {\n    const value = DEFAULT_THEME[key]\n    const color = value && (styles as any)[value]\n    if (\n      color\n      && typeof color.close === 'string'\n      && typeof color.open === 'string'","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/pretty-format/src/index.ts#L453-L489","documentation":"`format()` runs `validateOptions`, which rejects any options key not present in `DEFAULT_OPTIONS`. This catches typos and removed/renamed options early instead of silently ignoring them, and reports the offending key name.","triggerScenarios":"`format(value, { hilight: true })` (typo), or passing an option name from a different pretty-format version (e.g. jest's `printBasicPrototype` spelling drift), or a removed option after an upgrade.","commonSituations":"Migrating config from Jest's pretty-format; typos; copy-pasting options across versions; using an option that was renamed/removed.","solutions":["Cross-check the key against `DEFAULT_OPTIONS` in `packages/pretty-format/src/index.ts`.","Fix the typo or remove the unknown option.","If you need a behavior that no longer exists, find the replacement option in the changelog."],"exampleFix":"// before\nformat(value, { hilight: true, indent: 2 })\n\n// after\nformat(value, { highlight: true, indent: 2 })","handlingStrategy":"validation","validationCode":"import { DEFAULT_OPTIONS } from '@vitest/pretty-format'\n\nfunction assertOptions(opts: Record<string, unknown>) {\n  for (const key of Object.keys(opts)) {\n    if (!Object.prototype.hasOwnProperty.call(DEFAULT_OPTIONS, key)) {\n      throw new Error(`pretty-format: Unknown option '${key}'. Valid: ${Object.keys(DEFAULT_OPTIONS).join(', ')}`)\n    }\n  }\n}","typeGuard":"import type { OptionsReceived } from '@vitest/pretty-format'\n\nfunction isPrettyFormatOptions(v: unknown): v is OptionsReceived {\n  if (typeof v !== 'object' || v === null) return false\n  return Object.keys(v).every(k => k in DEFAULT_OPTIONS)\n}","tryCatchPattern":null,"preventionTips":["Type option objects as `OptionsReceived` so typos fail at compile time.","When migrating from Jest, diff your option keys against `DEFAULT_OPTIONS`.","Keep option builders centralized to avoid drift."],"tags":["pretty-format","options","validation"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}