|
15 | 15 | [![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends]
|
16 | 16 | [![MIT License][license-badge]][license]
|
17 | 17 |
|
18 |
| -[](#contributors) |
| 18 | +[](#contributors) |
19 | 19 | [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]
|
20 | 20 | [![Join the community on Spectrum][spectrum-badge]][spectrum]
|
21 | 21 |
|
@@ -285,6 +285,24 @@ module.exports = {
|
285 | 285 | }
|
286 | 286 | ```
|
287 | 287 |
|
| 288 | +There is the case when you want to wrap your components in a `Provider`, this |
| 289 | +might cause conflicts when `rerender`ed. To achieve this, we suggest the |
| 290 | +`rerender` should be implemented the same way custom queries, by changing the |
| 291 | +return value of the customRender. |
| 292 | + |
| 293 | +```js |
| 294 | +// test-utils.js |
| 295 | + |
| 296 | +const customRender = (node, ...options) => { |
| 297 | + const rendered = render(<div>{node}</div>, options) |
| 298 | + return { |
| 299 | + ...rendered, |
| 300 | + rerender: (ui, options) => |
| 301 | + customRender(ui, {container: rendered.container, ...options}), |
| 302 | + } |
| 303 | +} |
| 304 | +``` |
| 305 | + |
288 | 306 | #### Export Issue with Babel Versions Lower Than 7
|
289 | 307 |
|
290 | 308 | Babel versions lower than 7 throw an error when trying to override the named
|
@@ -639,7 +657,11 @@ class TestComponent extends React.Component {
|
639 | 657 | render() {
|
640 | 658 | const {count} = this.state
|
641 | 659 |
|
642 |
| - return <button onClick={() => this.setState({count: count + 1})}>Click to increase: {count}</button> |
| 660 | + return ( |
| 661 | + <button onClick={() => this.setState({count: count + 1})}> |
| 662 | + Click to increase: {count} |
| 663 | + </button> |
| 664 | + ) |
643 | 665 | }
|
644 | 666 | }
|
645 | 667 |
|
@@ -913,7 +935,8 @@ Some included are:
|
913 | 935 | - [`react-router`](https://github.com/kentcdodds/react-testing-library/blob/master/examples/__tests__/react-router.js)
|
914 | 936 | - [`react-context`](https://github.com/kentcdodds/react-testing-library/blob/master/examples/__tests__/react-context.js)
|
915 | 937 |
|
916 |
| -You can also find react-testing-library examples at [react-testing-examples.com](https://react-testing-examples.com/jest-rtl/). |
| 938 | +You can also find react-testing-library examples at |
| 939 | +[react-testing-examples.com](https://react-testing-examples.com/jest-rtl/). |
917 | 940 |
|
918 | 941 | ## Learning Material
|
919 | 942 |
|
@@ -1077,9 +1100,8 @@ libraries. I don't want my tests to wait for animations to end.
|
1077 | 1100 | ```javascript
|
1078 | 1101 | jest.mock('react-transition-group', () => {
|
1079 | 1102 | const FakeTransition = jest.fn(({children}) => children)
|
1080 |
| - const FakeCSSTransition = jest.fn( |
1081 |
| - props => |
1082 |
| - props.in ? <FakeTransition>{props.children}</FakeTransition> : null, |
| 1103 | + const FakeCSSTransition = jest.fn(props => |
| 1104 | + props.in ? <FakeTransition>{props.children}</FakeTransition> : null, |
1083 | 1105 | )
|
1084 | 1106 | return {CSSTransition: FakeCSSTransition, Transition: FakeTransition}
|
1085 | 1107 | })
|
@@ -1315,7 +1337,7 @@ Thanks goes to these people ([emoji key][emojis]):
|
1315 | 1337 | | [<img src="https://avatars2.githubusercontent.com/u/5286559?v=4" width="100px;"/><br /><sub><b>Mark Pollmann</b></sub>](https://markpollmann.com/)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=MarkPollmann "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/1213123?v=4" width="100px;"/><br /><sub><b>Ehtesham Kafeel</b></sub>](https://github.com/ehteshamkafeel)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=ehteshamkafeel "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=ehteshamkafeel "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1493505?v=4" width="100px;"/><br /><sub><b>Julio Pavón</b></sub>](http://jpavon.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=jpavon "Code") | [<img src="https://avatars3.githubusercontent.com/u/1765048?v=4" width="100px;"/><br /><sub><b>Duncan L</b></sub>](http://www.duncanleung.com/)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=duncanleung "Documentation") [💡](#example-duncanleung "Examples") | [<img src="https://avatars1.githubusercontent.com/u/700778?v=4" width="100px;"/><br /><sub><b>Tiago Almeida</b></sub>](https://www.linkedin.com/in/tyagow/?locale=en_US)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=tyagow "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/4982001?v=4" width="100px;"/><br /><sub><b>Robert Smith</b></sub>](http://rbrtsmith.com/)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3Arbrtsmith "Bug reports") | [<img src="https://avatars0.githubusercontent.com/u/1700355?v=4" width="100px;"/><br /><sub><b>Zach Green</b></sub>](https://offbyone.tech)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=zgreen "Documentation") |
|
1316 | 1338 | | [<img src="https://avatars3.githubusercontent.com/u/881986?v=4" width="100px;"/><br /><sub><b>dadamssg</b></sub>](https://github.com/dadamssg)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=dadamssg "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/8734097?v=4" width="100px;"/><br /><sub><b>Yazan Aabed</b></sub>](https://www.yaabed.com/)<br />[📝](#blog-YazanAabeed "Blogposts") | [<img src="https://avatars0.githubusercontent.com/u/556258?v=4" width="100px;"/><br /><sub><b>Tim</b></sub>](https://github.com/timbonicus)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3Atimbonicus "Bug reports") [💻](https://github.com/kentcdodds/react-testing-library/commits?author=timbonicus "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=timbonicus "Documentation") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=timbonicus "Tests") | [<img src="https://avatars3.githubusercontent.com/u/6682655?v=4" width="100px;"/><br /><sub><b>Divyanshu Maithani</b></sub>](http://divyanshu.xyz)<br />[✅](#tutorial-divyanshu013 "Tutorials") [📹](#video-divyanshu013 "Videos") | [<img src="https://avatars2.githubusercontent.com/u/9116042?v=4" width="100px;"/><br /><sub><b>Deepak Grover</b></sub>](https://www.linkedin.com/in/metagrover)<br />[✅](#tutorial-metagrover "Tutorials") [📹](#video-metagrover "Videos") | [<img src="https://avatars0.githubusercontent.com/u/16276358?v=4" width="100px;"/><br /><sub><b>Eyal Cohen</b></sub>](https://github.com/eyalcohen4)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=eyalcohen4 "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/7452681?v=4" width="100px;"/><br /><sub><b>Peter Makowski</b></sub>](https://github.com/petermakowski)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=petermakowski "Documentation") |
|
1317 | 1339 | | [<img src="https://avatars2.githubusercontent.com/u/20361668?v=4" width="100px;"/><br /><sub><b>Michiel Nuyts</b></sub>](https://github.com/Michielnuyts)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=Michielnuyts "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1195863?v=4" width="100px;"/><br /><sub><b>Joe Ng'ethe</b></sub>](https://github.com/joeynimu)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=joeynimu "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=joeynimu "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/19998290?v=4" width="100px;"/><br /><sub><b>Kate</b></sub>](https://github.com/Enikol)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=Enikol "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/11980217?v=4" width="100px;"/><br /><sub><b>Sean</b></sub>](http://www.seanrparker.com)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=SeanRParker "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/17031?v=4" width="100px;"/><br /><sub><b>James Long</b></sub>](http://jlongster.com)<br />[🤔](#ideas-jlongster "Ideas, Planning, & Feedback") [📦](#platform-jlongster "Packaging/porting to new platform") | [<img src="https://avatars1.githubusercontent.com/u/10118777?v=4" width="100px;"/><br /><sub><b>Herb Hagely</b></sub>](https://github.com/hhagely)<br />[💡](#example-hhagely "Examples") | [<img src="https://avatars2.githubusercontent.com/u/5779538?v=4" width="100px;"/><br /><sub><b>Alex Wendte</b></sub>](http://www.wendtedesigns.com/)<br />[💡](#example-themostcolm "Examples") |
|
1318 |
| -| [<img src="https://avatars0.githubusercontent.com/u/6998954?v=4" width="100px;"/><br /><sub><b>Monica Powell</b></sub>](http://www.aboutmonica.com)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=M0nica "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/2699953?v=4" width="100px;"/><br /><sub><b>Vitaly Sivkov</b></sub>](http://sivkoff.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=sivkoff "Code") | [<img src="https://avatars3.githubusercontent.com/u/7049?v=4" width="100px;"/><br /><sub><b>Weyert de Boer</b></sub>](https://github.com/weyert)<br />[🤔](#ideas-weyert "Ideas, Planning, & Feedback") [👀](#review-weyert "Reviewed Pull Requests") | |
| 1340 | +| [<img src="https://avatars0.githubusercontent.com/u/6998954?v=4" width="100px;"/><br /><sub><b>Monica Powell</b></sub>](http://www.aboutmonica.com)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=M0nica "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/2699953?v=4" width="100px;"/><br /><sub><b>Vitaly Sivkov</b></sub>](http://sivkoff.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=sivkoff "Code") | [<img src="https://avatars3.githubusercontent.com/u/7049?v=4" width="100px;"/><br /><sub><b>Weyert de Boer</b></sub>](https://github.com/weyert)<br />[🤔](#ideas-weyert "Ideas, Planning, & Feedback") [👀](#review-weyert "Reviewed Pull Requests") | [<img src="https://avatars3.githubusercontent.com/u/13613037?v=4" width="100px;"/><br /><sub><b>EstebanMarin</b></sub>](https://github.com/EstebanMarin)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=EstebanMarin "Documentation") | |
1319 | 1341 |
|
1320 | 1342 | <!-- ALL-CONTRIBUTORS-LIST:END -->
|
1321 | 1343 |
|
|
0 commit comments