docs/config/diff.md
string--diff=<path>DiffOptions object or a path to a module which exports DiffOptions. Useful if you want to customize diff display.
Vitest diff rendering uses @vitest/pretty-format under the hood and a part of DiffOptions is forwarded to the pretty-format configuration, while the rest affects diff rendering itself.
For example, as a config object:
import { defineConfig } from 'vitest/config'
import c from 'picocolors'
export default defineConfig({
test: {
diff: {
aIndicator: c.bold('--'),
bIndicator: c.bold('++'),
omitAnnotationLines: true,
},
},
})
Or as a module:
:::code-group
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
diff: './vitest.diff.ts',
},
})
import type { DiffOptions } from 'vitest'
import c from 'picocolors'
export default {
aIndicator: c.bold('--'),
bIndicator: c.bold('++'),
omitAnnotationLines: true,
} satisfies DiffOptions
:::
booleantrue--diff.expand=falseExpand all common lines.
number0--diff.truncateThreshold=<path>The maximum length of diff result to be displayed. Diffs above this threshold will be truncated. Truncation won't take effect with default value 0.
string'... Diff result is truncated'--diff.truncateAnnotation=<annotation>Annotation that is output at the end of diff result if it's truncated.
DiffOptionsColor = (arg: string) => stringnoColor = (string: string): string => stringColor of truncate annotation, default is output with no color.
booleanfalsePrint basic prototype Object and Array in diff output.
number20 (or 8 when comparing different types)Limit the depth to recurse when printing nested objects.