-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): print correct stack trace for unhandled errors (#6134)
- Loading branch information
1 parent
6e72114
commit 9997154
Showing
6 changed files
with
60 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/browser/fixtures/unhandled/throw-unhandled-error.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test } from 'vitest'; | ||
|
||
interface _Unused { | ||
_fake: never | ||
} | ||
|
||
test('unhandled exception', () => { | ||
;(async () => { | ||
throw new Error('custom_unhandled_error') | ||
})() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { defineConfig } from 'vitest/config' | ||
|
||
const provider = process.env.PROVIDER || 'playwright' | ||
const name = | ||
process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome') | ||
|
||
export default defineConfig({ | ||
cacheDir: fileURLToPath(new URL("./node_modules/.vite", import.meta.url)), | ||
test: { | ||
browser: { | ||
enabled: true, | ||
provider, | ||
name, | ||
headless: true, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect, test } from 'vitest' | ||
import { runBrowserTests } from './utils' | ||
|
||
test('prints correct unhandled error stack', async () => { | ||
const { stderr, browser } = await runBrowserTests({ | ||
root: './fixtures/unhandled', | ||
}) | ||
|
||
if (browser === 'webkit') { | ||
expect(stderr).toContain('throw-unhandled-error.test.ts:9:20') | ||
} | ||
else { | ||
expect(stderr).toContain('throw-unhandled-error.test.ts:9:10') | ||
} | ||
}) |