vitest-dev/vitest · error · Error

pretty-format: Options "min" and "indent" cannot be used tog

Error message

pretty-format: Options "min" and "indent" cannot be used together.

What it means

`min: true` requests single-line (minified) output, where indentation is meaningless. The validator rejects combining `min` with a non-zero `indent` because the two intents contradict; `indent: 0` alongside `min` is explicitly allowed.

Source

Thrown at packages/pretty-format/src/index.ts:476

  printBasicPrototype: true,
  printFunctionName: true,
  printShadowRoot: true,
  theme: DEFAULT_THEME,
  singleQuote: false,
  quoteKeys: true,
  spacingInner: '\n',
  spacingOuter: '\n',
} satisfies Options

function validateOptions(options: OptionsReceived) {
  for (const key of Object.keys(options)) {
    if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {
      throw new Error(`pretty-format: Unknown option "${key}".`)
    }
  }

  if (options.min && options.indent !== undefined && options.indent !== 0) {
    throw new Error(
      'pretty-format: Options "min" and "indent" cannot be used together.',
    )
  }
}

function getColorsHighlight(): Colors {
  return DEFAULT_THEME_KEYS.reduce((colors, key) => {
    const value = DEFAULT_THEME[key]
    const color = value && (styles as any)[value]
    if (
      color
      && typeof color.close === 'string'
      && typeof color.open === 'string'
    ) {
      colors[key] = color
    }
    else {
      throw new Error(

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Drop `indent` when using `min: true`.
  2. Or set `indent: 0` explicitly with `min` (this passes validation).
  3. Remove `min` if you actually want indented multi-line output.

Example fix

// before
format(value, { min: true, indent: 2 })

// after
format(value, { min: true })
// or
format(value, { min: true, indent: 0 })
Defensive patterns

Strategy: validation

Validate before calling

function resolveFormatOptions(opts: { min?: boolean; indent?: number } = {}) {
  if (opts.min && opts.indent !== undefined && opts.indent !== 0) {
    // pick one intent: minified wins, drop indent
    const { indent: _drop, ...rest } = opts
    return rest
  }
  return opts
}

format(value, resolveFormatOptions({ min: true, indent: 2 }))

Prevention

When it happens

Trigger: `format(value, { min: true, indent: 2 })`, or a shared config object that sets both for different call sites.

Common situations: Copying a config that set both; expecting indent to apply under min mode; merging option objects where one sets min and another sets indent.

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/baefa5d734bd50e0.json. Report an issue: GitHub.