Skip to content
项目

epicweb-dev/react-component-testing-with-vitest

在 GitHub 查看

关于

Test your React components in the actual browser with Vitest Browser Mode.

网站与应用开发

这些数字如何统计

实测星标增长

24小时
正在收集历史
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

React Component Testing with Vitest

Learn how to test React components in the actual browser with Vitest.


Build Status GPL 3.0 License Code of Conduct

Prerequisites

You don't have to have any prior experience with Vitest or Vitest Browser Mode to complete this workshop.

  • A basic experience with TypeScript is required.
  • A basic experience with component-level testing is beneficial. This workshop works best if you've written component tests in the past. But don't worry if you haven't, you will write a bunch of those during the workshop!
  • Get familiar with React Testing Library, especially its Guiding Principles. You don't need to have any prior experience of using the library.

Pre-workshop Resources

Here are some resources you can read before taking the workshop to get you up to speed on some of the tools and concepts we'll be covering:

System Requirements

  • git v2.18 or greater
  • NodeJS v22 or greater
  • npm v8 or greater

All of these must be available in your PATH. To verify things are set up properly, you can run this:

git --version
node --version
npm --version

If you have trouble with any of these, learn more about the PATH environment variable and how to fix it here for windows or mac/linux.

Setup

Use the Epic Workshop CLI to get this setup:

npx --yes epicshop@latest add react-component-testing-with-vitest

If you experience errors here, please open an issue with as many details as you can offer.

The Workshop App

Learn all about the workshop app on the Epic Web Getting Started Guide.

Kent with the workshop app in the background

Troubleshooting

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'epicshop'

Reason: You likely have ignore-scripts=true in your .npmrc, which skips the postinstall script that installs the workshop app.

Solution: Remove ignore-scripts=true from your ~/.npmrc and run the setup command again.

Could not locate workshop-app directory

Reason: You ran npx epicshop start, which uses the globally installed epicshop CLI that cannot find the workshop app.

Solution: Either one of the following:

  • Run npm start in the workshop directory instead;
  • Install the workshop app globally with npm install -g @epic-web/workshop-app and run the epicshop start command again.

探索相关项目

加载中…