File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,43 @@ const App = () => (
147147export default App;
148148```
149149
150+ ## Unit Test Your App with Vitest
151+
152+ Vitest is a fast and efficient unit testing framework designed specifically for the Vite ecosystem.
153+
154+ To enable it, start by adding the dependencies:
155+
156+ ``` sh
157+ yarn add -D vitest @vitest/browser playwright
158+ ```
159+
160+ Then modify and use the following configs:
161+
162+ ``` diff
163+ // in vite.config.ts
164+
165+ + /// <reference types="vitest" />
166+ import { defineConfig } from 'vite';
167+ import react from '@vitejs/plugin-react-swc';
168+
169+ // https://vitejs.dev/config/
170+ export default defineConfig({
171+ plugins: [react()],
172+ + test: {
173+ + browser: {
174+ + enabled: true,
175+ + provider: "playwright",
176+ + instances: [
177+ + {
178+ + browser: "chromium",
179+ + },
180+ + ],
181+ + },
182+ + globals: true,
183+ + },
184+ });
185+ ```
186+
150187## Troubleshooting
151188
152189### Error about ` global ` Being ` undefined `
You can’t perform that action at this time.
0 commit comments