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

Added documentation for verbose flag on debug #2104

Merged
merged 1 commit into from Apr 23, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 21 additions & 5 deletions docs/api/ReactWrapper/debug.md
Expand Up @@ -31,7 +31,7 @@ function Bar() {
return (
<div className="bar">
<span>Non-Foo</span>
<Foo baz="bax" />
<Foo baz="bax" object={{ a: 1, b: 2 }} />
</div>
);
}
Expand All @@ -44,13 +44,13 @@ console.log(mount(<Bar id="2" />).debug());

Would output the following to the console:
<!-- eslint-disable -->
```jsx
```text
<Bar id="2">
<div className="bar">
<span>
Non-Foo
</span>
<Foo baz="bax">
<Foo baz="bax" object={{...}}>
<div className="foo">
<span>
Foo
Expand All @@ -68,7 +68,7 @@ console.log(mount(<Bar id="2" />).find(Foo).debug());
```
Would output the following to the console:
<!-- eslint-disable -->
```jsx
```text
<Foo baz="bax">
<div className="foo">
<span>
Expand All @@ -83,7 +83,7 @@ console.log(mount(<Bar id="2" />).find(Foo).debug({ ignoreProps: true }));
```
Would output the following to the console:
<!-- eslint-disable -->
```jsx
```text
<Foo>
<div>
<span>
Expand All @@ -92,3 +92,19 @@ Would output the following to the console:
</div>
</Foo>
```

and:
```jsx
console.log(mount(<Bar id="2" />).find(Foo).debug({ verbose: true }));
```
Would output the following to the console:
<!-- eslint-disable -->
```text
<Foo baz="bax" object={{ a: 1, b: 2 }}>
<div className="foo">
<span>
Foo
</span>
</div>
</Foo>
```
34 changes: 29 additions & 5 deletions docs/api/ShallowWrapper/debug.md
Expand Up @@ -8,6 +8,7 @@ console when tests are not passing when you expect them to.

`options` (`Object` [optional]):
- `options.ignoreProps`: (`Boolean` [optional]): Whether props should be omitted in the resulting string. Props are included by default.
- `options.verbose`: (`Boolean` [optional]): Whether arrays and objects passed as props should be verbosely printed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add examples below of both ignoreProps and verbose output?


#### Returns

Expand All @@ -21,7 +22,12 @@ function Book({ title, pages }) {
return (
<div>
<h1 className="title">{title}</h1>
{pages && <NumberOfPages pages={pages} />}
{pages && (
<NumberOfPages
pages={pages}
object={{ a: 1, b: 2 }}
/>
)}
</div>
);
}
Expand Down Expand Up @@ -56,8 +62,8 @@ console.log(wrapper.debug());
Outputs to console:
```text
<div>
<h1 className="title">Huckleberry Finn</h1>
<NumberOfPages pages="633 pages" />
<h1 className="title">Huckleberry Finn</h1>
<NumberOfPages pages="633 pages" object={{...}}/>
</div>
```

Expand All @@ -73,7 +79,25 @@ console.log(wrapper.debug({ ignoreProps: true }));
Outputs to console:
```text
<div>
<h1>Huckleberry Finn</h1>
<NumberOfPages />
<h1>Huckleberry Finn</h1>
<NumberOfPages />
</div>
```


```jsx
const wrapper = shallow((
<Book
title="Huckleberry Finn"
pages="633 pages"
/>
));
console.log(wrapper.debug({ verbose: true }));
```
Outputs to console:
```text
<div>
<h1 className="title">Huckleberry Finn</h1>
<NumberOfPages pages="633 pages" object={{ a: 1, b: 2 }}/>
</div>
```