vitest-dev/vitest · error · Error
pretty-format: Options "min" and "indent" cannot be used…
Error message
pretty-format: Options "min" and "indent" cannot be used together.
What it means
validateOptions rejects the combination of the 'min' option (single-line minimal output) with a non-zero 'indent' option, since they are semantically incompatible: min mode collapses whitespace and indentation has no meaning. Only indent: 0 (or undefined) is allowed with min.
Example fix
// before
format(value, { min: true, indent: 4 })
// after
format(value, { min: true }) Defensive patterns
Strategy: validation
Validate before calling
if (options.min && options.indent != null && options.indent !== 0) {
throw new Error('min and indent are incompatible; dropping indent')
}
const { indent, ...rest } = options
format(value, options.min ? rest : options) Type guard
function optionsAreCompatible(o: { min?: boolean; indent?: number }): boolean { return !(o.min && o.indent != null && o.indent !== 0) } Prevention
- When enabling min, delete indent from the config
- Build configs from a single source so conflicts surface
- Assert option compatibility in config tests
When it happens
Trigger: Calling format(value, { min: true, indent: 4 }); or a config layer merging min: true with a pre-set indent value.
Common situations: Inheriting a base config with indent and then enabling min; merging user config over defaults without reconciling the two; CI config setting both.
Related errors
- pretty-format: Unknown option
- Asymmetric matcher does not implement toAsymmetricMatcher()
- error.message
- Exact option does not support RegExp expected class names
- Expected a single value for option
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/baefa5d734bd50e0.
Report an issue: GitHub.
Appendix: 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 1fa9837ec2)