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

Update testing section #1404

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

kligarski
Copy link

@kligarski kligarski commented Feb 20, 2025

This PR is a continuation of (#1374).

Description

Adding examples to the testing section of the documentation ("Testing with Jest").

Changes

  • changed setup of mocking react-native-reanimated and added a link to the docs of Reanimated,
  • added example of mocking react-native-screens (from previous PR),
  • added new real-life examples:
    • navigation between tabs (simple tab change, without fake timers),
    • reacting to navigation events (text showing after animation ends (stack naviagator), fake timers introduced),
    • example with stack, tabs and tabPress,
    • example with useFocusEffect and data fetching
  • fixed getBy vs queryBy according to the suggestion from the previous PR (Update testing section #1374 (comment))

Copy link

netlify bot commented Feb 20, 2025

Deploy Preview for react-navigation-docs ready!

Name Link
🔨 Latest commit 508b203
🔍 Latest deploy log https://app.netlify.com/sites/react-navigation-docs/deploys/67bd70fde3437b0008bd5ef8
😎 Deploy Preview https://deploy-preview-1404--react-navigation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kkafar kkafar mentioned this pull request Feb 20, 2025
@kligarski
Copy link
Author

In the Example 4, adding jest.useFakeTimers() even without running the timers fixes an issue with React state update warnings from React Testing Library (they sometimes appear when running the test). I tried wrapping various parts of the test in act with no success. I suspect it is connected with fetching the data asynchronously but I'm not sure what the issue is exactly and why using fake timers helps with this problem.

@kligarski kligarski marked this pull request as ready for review February 24, 2025 10:14
@kligarski
Copy link
Author

@kkafar

Copy link

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

Looks good to me! I've added few suggestions & changes requests.

IMO this is is.

I'll want to get input from @satya164 before merging though.

@kligarski kligarski requested a review from kkafar February 25, 2025 07:29
Copy link

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

We need to improve the PR description slightly before we land it.
Other than that - great job. Also shoutout to @AnCichocka for the bulk of the work.

@kkafar kkafar requested a review from satya164 February 25, 2025 11:15
@kligarski
Copy link
Author

PR description updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants