Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack trace incorrect for unhandled errors during test run in browser mode #6112

Closed
6 tasks done
kwojcik opened this issue Jul 12, 2024 · 0 comments · Fixed by #6134
Closed
6 tasks done

stack trace incorrect for unhandled errors during test run in browser mode #6112

kwojcik opened this issue Jul 12, 2024 · 0 comments · Fixed by #6134
Labels
feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@kwojcik
Copy link
Sponsor

kwojcik commented Jul 12, 2024

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.2

Used Package Manager

npm

Validations

@sheremet-va sheremet-va added feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jul 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants