Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on prettyDOM options parameter #181

Merged
merged 1 commit into from
Jul 9, 2019
Merged
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
17 changes: 13 additions & 4 deletions docs/dom-testing-library/api-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,26 @@ you'd like a solution that works for both, see

### `prettyDOM`

This helper function can be used to print out readable representation of the DOM
Built on top of
[`pretty-format`](https://github.com/facebook/jest/tree/master/packages/pretty-format),
this helper function can be used to print out readable representation of the DOM
tree of a node. This can be helpful for instance when debugging tests.

It is defined as:

```typescript
function prettyDOM(node: HTMLElement, maxLength?: number): string
function prettyDOM(
node: HTMLElement,
maxLength?: number,
options?: Options
): string
```

It receives the root node to print out, and an optional extra argument to limit
the size of the resulting string, for cases when it becomes too large.
It receives the root node to print out, an optional extra parameter to limit the
size of the resulting string, for cases when it becomes too large. It has a last
parameter which allows you to configure your formatting as defined in the
[options](https://github.com/facebook/jest/tree/master/packages/pretty-format#usage-with-options)
of `pretty-format`.

This function is usually used alongside `console.log` to temporarily print out
DOM trees during tests for debugging purposes:
Expand Down