@@ -182,22 +182,50 @@ snapshotDiff(firstVersion, container.cloneNode(true))
182182
183183<summary >How do I fix "an update was not wrapped in act(...)" warnings?</summary >
184184
185- This warning is usually caused by an async operation causing an update after
186- the test has already finished. There are 2 approaches to resolve it:
185+ This warning is usually caused by an async operation causing an update after the
186+ test has already finished. There are 2 approaches to resolve it:
187187
1881881 . Wait for the result of the operation in your test by using one of
189189 [ the async utilities] ( /docs/dom-testing-library/api-async ) like
190190 [ wait] ( /docs/dom-testing-library/api-async#wait ) or a
191191 [ ` find* ` query] ( /docs/dom-testing-library/api-queries#findby ) . For example:
192192 ` const userAddress = await findByLabel(/address/i) ` .
193- 2 . Mocking out the asynchronous operation so that it doesn't trigger state updates.
193+ 2 . Mocking out the asynchronous operation so that it doesn't trigger state
194+ updates.
194195
195- Generally speaking, approach 1 is preferred since it better matches the expectations
196- of a user interacting with your app.
196+ Generally speaking, approach 1 is preferred since it better matches the
197+ expectations of a user interacting with your app.
197198
198199In addition, you may find
199- [ this blog post] ( https://kentcdodds.com/blog/write-fewer-longer-tests ) helpful as you
200- consider how best to write tests that give you confidence and avoid these warnings.
200+ [ this blog post] ( https://kentcdodds.com/blog/write-fewer-longer-tests ) helpful
201+ as you consider how best to write tests that give you confidence and avoid these
202+ warnings.
203+
204+ </details >
205+
206+ <details >
207+
208+ <summary >What level of a component tree should I test? Children, parents, or both?</summary >
209+
210+ Following the guiding principle of this library, it is useful to break down how
211+ tests are organized around how the user experiences and interacts with
212+ application functionality rather than around specific components themselves. In
213+ some cases, for example for reusable component libraries, it might be useful to
214+ include developers in the list of users to test for and test each of the
215+ reusable components individually. Other times, the specific break down of a
216+ component tree is just an implementation detail and testing every component
217+ within that tree individually can cause issues (see
218+ https://kentcdodds.com/blog/avoid-the-test-user ).
219+
220+ In practice this means that it is often preferable to test high enough up the
221+ component tree to simulate realistic user interactions. The question of whether
222+ it is worth additionally testing at a higher or lower level on top of this comes
223+ down to a question of tradeoffs and what will provide enough value for the cost
224+ (see https://kentcdodds.com/blog/unit-vs-integration-vs-e2e-tests on more info
225+ on different levels of testing).
226+
227+ For a more in-depth discussion of this topic see
228+ [ this video] ( https://youtu.be/0qmPdcV-rN8 ) .
201229
202230</details >
203231
0 commit comments