-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Description
Describe the bug
In vitest 4.0.16 browser mode (@vitest/browser + Playwright runner), when console.error is called with an object containing Symbol properties, the baseFormat function in @vitest/utils throws a TypeError.
This commonly occurs with RTK Query error objects, which contain Symbol keys like Symbol() as internal markers. For example:
// RTK Query error object structure (simplified)
{
status: "FETCH_ERROR",
error: "...",
[Symbol()]: "internal marker" // This causes the crash
}This is a regression from 4.0.15.
Reproduction
https://github.com/Suto-Michimasa/vitest-symbol-repro
Steps to reproduce
git clone https://github.com/Suto-Michimasa/vitest-symbol-repro
cd vitest-symbol-repro
pnpm install
pnpm test:browserStack trace
TypeError: Cannot convert a Symbol value to a string
at baseFormat (@vitest/[email protected]/dist/display.js:700:15)
at browserFormat (@vitest/[email protected]/dist/display.js:711:9)
at processLog (__vitest_browser__/tester.js:1202:10)
at console.error (__vitest_browser__/tester.js:1198:23)
Regression confirmation
Downgrading to 4.0.15 resolves the issue:
pnpm up [email protected] @vitest/[email protected] @vitest/[email protected]
pnpm test:browser # passesExpected behavior
- Symbol properties should be safely handled during console output formatting (ignored or converted via
String(symbol)) - Tests should pass without TypeError
Actual behavior
- Tests fail with
TypeError: Cannot convert a Symbol value to a string - The browser runner crashes when formatting objects with Symbol keys
System Info
- vitest: 4.0.16
- @vitest/browser: 4.0.16
- @vitest/browser-playwright: 4.0.16
- playwright: 1.57.0
- Browser: Chromium (via Playwright)
- Node.js: 20+
- OS: macOSUsed Package Manager
pnpm
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.