Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/06-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,21 @@ export default ({projectDir}) => {
```

Note that the final configuration must not be a promise.

## Object printing depth

By default, AVA prints nested objects to a depth of `3`. However, when debugging tests with deeply nested objects, it can be useful to print with more detail. This can be done by setting [`util.inspect.defaultOptions.depth`](https://nodejs.org/api/util.html#util_util_inspect_defaultoptions) to the desired depth, before the test is executed:

```js
import util from 'util';

import test from 'ava';

util.inspect.defaultOptions.depth = 5; // Increase AVA's printing depth

test('My test', t => {
t.deepEqual(someDeeplyNestedObject, theExpectedValue);
});
```

AVA has a minimum depth of `3`.
12 changes: 11 additions & 1 deletion lib/concordance-options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const util = require('util');
const ansiStyles = require('ansi-styles');
const stripAnsi = require('strip-ansi');
const cloneDeepWith = require('lodash.clonedeepwith');
Expand Down Expand Up @@ -124,6 +125,15 @@ const plainTheme = cloneDeepWith(colorTheme, value => {
});

const theme = chalk.enabled ? colorTheme : plainTheme;
exports.default = {maxDepth: 3, plugins, theme};

exports.default = {
// Use Node's object inspection depth, clamped to a minimum of 3
get maxDepth() {
return Math.max(3, util.inspect.defaultOptions.depth);
},
plugins,
theme
};

exports.diff = {maxDepth: 1, plugins, theme};
exports.snapshotManager = {plugins, theme: plainTheme};