-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Describe the bug
When I run the vitest command I get the following error:
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: × Expected ';', '}' or <eof>
╭─[/__vitest_test__/__test__/3f88ef57-aceb-412a-b54a-57248d1f6580/%2FUsers%2Ftgrigorov%2FCode%2Fmy-vite-app%2Fsrc%2FApp.test.tsx:2:1]
1 │
2 │ html {
· ──┬─ ─
· ╰── This is the expression part of an expression statement
3 │ padding: 0;
4 │ margin: 0;
5 │ }
╰────
Caused by:
Syntax Error
1 |
2 | html {
| ^
3 | padding: 0;
4 | margin: 0;
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
test: {
globals: true,
browser: {
enabled: true,
name: "chromium",
headless: true,
provider: "playwright",
screenshotFailures: false,
},
},
});
// App.test.tsx
import {test} from 'vitest'
import { render } from 'vitest-browser-react';
import App from './App';
test('App', () => {
render(<App />)
})
Any help on debugging/mitigation would be appreciated!
Reproduction
- Clone https://github.com/todorgrigorov/vitest-browser-bug
npm inpx vitest- Observe error in browser/terminal
System Info
System:
OS: macOS 15.0.1
CPU: (11) arm64 Apple M3 Pro
Memory: 107.03 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.17.0/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 9.12.0 - /opt/homebrew/bin/pnpm
Browsers:
Brave Browser: 129.1.70.119
Chrome: 130.0.6723.92
Safari: 18.0.1
npmPackages:
@vitejs/plugin-react-swc: ^3.5.0 => 3.7.1
@vitest/browser: ^2.1.4 => 2.1.4
vite: ^5.4.10 => 5.4.10
vitest: ^2.1.4 => 2.1.4Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable