Skip to content

API Reference / @gtkx/testing / prettyFormat / PrettyFormatOptions

Interface: PrettyFormatOptions ​

Properties ​

callToJSON? ​

optional callToJSON?: boolean

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

Default ​

ts
true

compareKeys? ​

optional compareKeys?: CompareKeys

Compare function used when sorting object keys. Set to null to disable sorting.


escapeRegex? ​

optional escapeRegex?: boolean

Whether to escape special characters in regular expressions.

Default ​

ts
false

escapeString? ​

optional escapeString?: boolean

Whether to escape special characters in strings.

Default ​

ts
true

highlight? ​

optional highlight?: boolean

Whether to highlight syntax using terminal colors.

Default ​

ts
false

indent? ​

optional indent?: number

Number of spaces to use for each level of indentation.

Default ​

ts
2

maxDepth? ​

optional maxDepth?: number

Maximum depth to recurse into nested values.

Default ​

ts
Infinity

maxOutputLength? ​

optional 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

maxWidth? ​

optional maxWidth?: number

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

Default ​

ts
Infinity

min? ​

optional 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

plugins? ​

optional plugins?: Plugins

Plugins used to serialize application-specific data types.

Default ​

ts
[]

printBasicPrototype? ​

optional 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.


printFunctionName? ​

optional printFunctionName?: boolean

Whether to include the function name when formatting functions.

Default ​

ts
true

printShadowRoot? ​

optional printShadowRoot?: boolean

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

Default ​

ts
true

quoteKeys? ​

optional 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

singleQuote? ​

optional singleQuote?: boolean

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

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

Default ​

ts
false

spacingInner? ​

optional 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.


spacingOuter? ​

optional 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.