Skip to main content
Version: v7

Testing Ionic React

This document provides an overview of how to test an application built with @ionic/react. It covers the basics of testing with React, as well as the specific tools and libraries used in @ionic/react.

Introduction

Testing is an important part of the development process, and it helps to ensure that an application is working as intended. In @ionic/react, testing is done using a combination of tools and libraries, including Vitest, Jest, React Testing Library, Playwright or Cypress.

Types of Tests

There are two types of tests that can be written:

Unit Tests: Unit tests are used to test individual functions and components in isolation. They can be written using tools such as Jest and React Testing Library or Vitest.

Integration Tests: Integration tests are used to test how different components work together. They can be written using tools such as Cypress or Playwright.

Tools and Libraries

Unit Testing

Jest: Jest is a popular testing framework for JavaScript applications. It is included with react-scripts and is used to run unit tests.

Vitest: Vitest is a modern testing framework powered by Vite. It is compatible with Jest and is used to run unit tests.

React Testing Library: React Testing Library is a set of utilities that make it easy to test React components. It's used to interact with components and test their behavior.

Integration Testing

Cypress: Cypress is a modern testing tool that's used to run end-to-end tests. It allows developers to test the entire application, including the user interface, in a simulated environment.

Playwright: Playwright is a browser automation library that's used to run end-to-end tests. It allows developers to test the entire application, including the user interface, in a simulated environment.

Additional Resources