Skip to content

API Reference / @gtkx/testing / prettyFormat / Options

Interface: Options ​

Extends ​

  • Omit<RequiredOptions, "compareKeys" | "theme">

Properties ​

callToJSON ​

callToJSON: boolean

Call toJSON on objects before formatting them. Ignored after the formatter has already called toJSON once for a value.

Default ​

ts
true

Inherited from ​

PrettyFormatOptions.callToJSON


compareKeys ​

compareKeys: CompareKeys


escapeRegex ​

escapeRegex: boolean

Whether to escape special characters in regular expressions.

Default ​

ts
false

Inherited from ​

PrettyFormatOptions.escapeRegex


escapeString ​

escapeString: boolean

Whether to escape special characters in strings.

Default ​

ts
true

Inherited from ​

PrettyFormatOptions.escapeString


highlight ​

highlight: boolean

Whether to highlight syntax using terminal colors.

Default ​

ts
false

Inherited from ​

PrettyFormatOptions.highlight


indent ​

indent: number

Number of spaces to use for each level of indentation.

Default ​

ts
2

Inherited from ​

PrettyFormatOptions.indent


maxDepth ​

maxDepth: number

Maximum depth to recurse into nested values.

Default ​

ts
Infinity

Inherited from ​

PrettyFormatOptions.maxDepth


maxOutputLength ​

maxOutputLength: number

Approximate per-depth-level budget for output length. When the accumulated output at any single depth level exceeds this value, further nesting is collapsed. This is a heuristic safety valve, not a hard limit — total output can reach up to roughly maxDepth × maxOutputLength.

Default ​

ts
1_000_000

Inherited from ​

PrettyFormatOptions.maxOutputLength


maxWidth ​

maxWidth: number

Maximum number of items to print in arrays, sets, maps, and similar collections.

Default ​

ts
Infinity

Inherited from ​

PrettyFormatOptions.maxWidth


min ​

min: boolean

Whether to minimize added whitespace, including indentation and line breaks.

When true, pretty-format defaults spacingInner to ' ', spacingOuter to '', and ignores indentation. It also changes the default for printBasicPrototype from true to false, although an explicit printBasicPrototype still wins. Explicit spacingInner / spacingOuter overrides still apply.

Default ​

ts
false

Inherited from ​

PrettyFormatOptions.min


plugins ​

plugins: Plugins

Plugins used to serialize application-specific data types.

Default ​

ts
[]

Inherited from ​

PrettyFormatOptions.plugins


printBasicPrototype ​

printBasicPrototype: boolean

Whether to print Object / Array prefixes for plain objects and arrays.

Defaults to true, unless min is true, in which case it defaults to false. An explicit printBasicPrototype value always overrides the min default.

Inherited from ​

PrettyFormatOptions.printBasicPrototype


printFunctionName ​

printFunctionName: boolean

Whether to include the function name when formatting functions.

Default ​

ts
true

Inherited from ​

PrettyFormatOptions.printFunctionName


printShadowRoot ​

printShadowRoot: boolean

Whether to include shadow-root contents when formatting DOM nodes.

Default ​

ts
true

Inherited from ​

PrettyFormatOptions.printShadowRoot


quoteKeys ​

quoteKeys: boolean

Whether to always quote object property keys.

For example: {"a": 1} when true{a: 1} when false and the key is a valid identifier {"my-key": 1} still stays quoted because it is not a valid identifier

Default ​

ts
true

Inherited from ​

PrettyFormatOptions.quoteKeys


singleQuote ​

singleQuote: boolean

Whether to print strings using single quotes instead of double quotes.

For example: "hello" when false'hello' when true

Default ​

ts
false

Inherited from ​

PrettyFormatOptions.singleQuote


spacingInner ​

spacingInner: string

Whitespace inserted after commas between items or entries.

For example, in {a: 1, b: 2} or [1, 2], this controls the gap after each comma: {a: 1,${spacingInner}b: 2}[1,${spacingInner}2]

Defaults to '\n' in regular mode and ' ' when min is true. Can be overridden independently of min.

Inherited from ​

PrettyFormatOptions.spacingInner


spacingOuter ​

spacingOuter: string

Whitespace inserted immediately inside collection/object delimiters.

For example, this controls the space or newline right after the opening delimiter and right before the closing delimiter: {${spacingOuter}a: 1${spacingOuter}}[${spacingOuter}1${spacingOuter}]

Defaults to '\n' in regular mode and '' when min is true. Can be overridden independently of min.

Inherited from ​

PrettyFormatOptions.spacingOuter


theme ​

theme: Theme