测试 Ionic React
¥Testing Ionic React
本文档概述了如何测试使用 @ionic/react
构建的应用。它涵盖了 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 developers can use to test their applications.
介绍
¥Introduction
测试是开发过程的重要组成部分,它有助于确保应用按预期工作。在 @ionic/react
中,测试是使用工具和库的组合来完成的,包括 Jest 或 Vitest、React 测试库、Playwright 或 Cypress。
¥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 Jest or Vitest, React Testing Library, Playwright or Cypress.
测试类型
¥Types of Tests
可以编写两种类型的测试:
¥There are two types of tests that can be written:
单元测试:单元测试用于单独测试各个功能和组件。Jest、Vitest 和 反应测试库 通常用于单元测试。
¥Unit Tests: Unit tests are used to test individual functions and components in isolation. Jest, Vitest and React Testing Library are commonly used for unit testing.
集成测试:集成测试用于测试不同组件如何协同工作。Cypress 或 Playwright 通常用于集成测试。
¥Integration Tests: Integration tests are used to test how different components work together. Cypress or Playwright are commonly used for integration testing.