The ultimate guide on how to test the navigation in React native.
-
Setting up the development environment: https://reactnative.dev/docs/environment-setup.
-
Install dependencies:
yarn install
-
Run on Android/iOS/Real device:
expo start
-
Run all test:
yarn test
-
Run all test with coverage:
yarn test:coverage
Here are all the possible test you can run:
- Unit tests:
- Basic navigate test with navigation mocked locally π
src/tests/unit/Home.component.test.tsx
- Basic navigate test with navigation mocked locally π
- Integration tests:
- Navigation between pages π
src/tests/integration/navigation-between-pages.test.tsx
- Interaction with nav header & nav params π
src/tests/integration/navigation-header-and-params.test.tsx
- useFocusEffect test π
src/tests/integration/useFocusEffect-view-counter.test.tsx
- Navigation between pages π