Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OlimpiaZurek committed Nov 22, 2024
1 parent 796dec1 commit c666ade
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test('toggles state when clicked', () => {
### Don’ts

- Don’t test implementation details (e.g., state variables or internal method calls).
- Don’t ignore warnings: Fix `act()` or other common warnings to ensure reliability. The `act()`function ensures that any updates to the state or props of a component (including rendering, firing events, or manual state updates) are completed before the test proceeds. The RNTL automatically wraps most rendering and interaction utilities (`render`, `fireEvent`, `waitFor`, etc.) in `act()` to manage these updates. However, there are some situations where manual use of `act()` might be necessary, particularly when dealing with asynchronous logic, animations or timers(`setTimeOut`, `setInterval` etc). You can find more detailed explanation [here](https://callstack.github.io/react-native-testing-library/docs/advanced/understanding-act).
- Don’t ignore warnings: Fix `act()` or other common warnings to ensure reliability. The `act()` function ensures that any updates to the state or props of a component (including rendering, firing events, or manual state updates) are completed before the test proceeds. The RNTL automatically wraps most rendering and interaction utilities (`render`, `fireEvent`, `waitFor`, etc.) in `act()` to manage these updates. However, there are some situations where manual use of `act()` might be necessary, particularly when dealing with asynchronous logic, animations or timers (`setTimeout`, `setInterval` etc). You can find more detailed explanation [here](https://callstack.github.io/react-native-testing-library/docs/advanced/understanding-act).
- Avoid over-mocking: Mock dependencies sparingly to maintain realistic tests.
- *Bad*: Mocking a child component unnecessarily.
- *Good*: Mocking a network request while testing component interactions.
Expand Down

0 comments on commit c666ade

Please sign in to comment.