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 file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.