Skip to content

Unit, Integration & Snapshot Testing

Martha Sharpe edited this page Feb 8, 2021 · 3 revisions

This app uses Jest with React Native Testing Library for unit and integration tests. It also utilizes snapshot testing.

Snapshot testing renders a UI component, takes a snapshot, then compares it to a reference snapshot file stored alongside the test. The test will fail if the two snapshots do not match.

Packages

Jest is a widely used JavaScript unit testing framework that is compatible with TypeScript and React.

Jest Expo is a Jest preset that mocks out the native side of the Expo SDK and handles some of the configuration.

React Native Testing Library is a solution for testing React Native components. It provides light utility functions on top of React Test Renderer.

Redux Mock Store creates a mock Redux store for async action creators using Redux Thunk or other middleware.

Jest Fetch Mock mocks fetch requests to the API.

Configuration

In the root folder, there is a jest folder with a setup file. This file contains the necessary configuration for React Navigation.

This folder also contains a renderWithRedux file, which is a custom render function used to test components which are connected to the Redux store.

package.json contains additional jest configuration including transformIgnorePatterns.

Clone this wiki locally