-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
feat: browserIssues and PRs related to the browser runnerIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
If your test has an unhandled error, the printed stack trace is wrong in browser mode
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.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: oops
❯ test/basic.test.tsx:7:11
5| });
6|
7| test("fails", async () => {
| ^
8| setTimeout(() => {
9| throw new Error("oops");
Reproduction
https://github.com/kwojcik/vitestsourcemapbug/tree/uncaughtErrorSourcemap
git checkout uncaughtErrorSourcemap
npm install
npm run test
import { expect, test } from "vitest";
test("passes", () => {
expect(true).toBe(true);
});
test("fails", async () => {
setTimeout(() => {
throw new Error("oops");
}, 100);
await new Promise((r) => setTimeout(r, 1000));
});
System Info
System:
OS: macOS 13.6.7
CPU: (12) arm64 Apple M2 Max
Memory: 16.67 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.18.2 - ~/.asdf/installs/nodejs/18.18.2/bin/node
Yarn: 1.22.22 - ~/.asdf/installs/nodejs/18.18.2/bin/yarn
npm: 9.8.1 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 9.5.0 - ~/.asdf/installs/nodejs/18.18.2/bin/pnpm
Watchman: 2024.04.01.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 126.0.6478.127
Firefox Nightly: 127.0
Safari: 16.6
npmPackages:
@vitest/browser: 2.0.2 => 2.0.2
@vitest/ui: 2.0.2 => 2.0.2
vite: latest => 5.3.2
vitest: 2.0.2 => 2.0.2Used 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.
Metadata
Metadata
Assignees
Labels
feat: browserIssues and PRs related to the browser runnerIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)