-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(ui): show unhandled errors on the ui #4380
Changes from 13 commits
edfc76b
ed06d00
3a71dc1
753885e
2f103fc
e80dd91
d0d0863
88ddb3d
a75c1f2
2e4a8a4
8afb14e
b5e42a5
eafe0de
311c2fb
1c7607a
0557eb9
7dd446f
a491c46
ca3a82e
5311c62
db4f07d
b6de84a
65f01f3
0e59875
68f9407
a8da5cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,60 @@ | ||||||
<script setup lang="ts"> | ||||||
import { isPrimitive } from 'vitest/utils' | ||||||
|
||||||
const props = defineProps<{ | ||||||
error: unkown | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh wow, how did that even work |
||||||
}>() | ||||||
|
||||||
let e = props.error as ErrorWithDiff; | ||||||
|
||||||
if (isPrimitive(props.error)) { | ||||||
e = { | ||||||
message: String(error).split(/\n/g)[0], | ||||||
stack: String(error), | ||||||
name: '' | ||||||
} | ||||||
} | ||||||
|
||||||
if (!e) { | ||||||
const error = new Error('unknown error') | ||||||
e = { | ||||||
message: error.message, | ||||||
stack: error.stack, | ||||||
name: '' | ||||||
} | ||||||
} | ||||||
</script> | ||||||
|
||||||
<template> | ||||||
<h4 bg="red500/10" p-1 mb-1 mt-2 rounded> | ||||||
<span font-bold> | ||||||
{{ e.name || e.nameStr || 'Unknown Error' }}<template v-if="e.message">:</template> | ||||||
</span> | ||||||
{{ e.message }} | ||||||
</h4> | ||||||
<p v-if="e.VITEST_TEST_PATH" text="sm" font-thin mb-2> | ||||||
This error originated in <span font-bold>{{ e.VITEST_TEST_PATH }}</span> test file. It doesn't mean the error was thrown inside the file itself, but while it was running. | ||||||
</p> | ||||||
<p v-if="e.VITEST_TEST_NAME" text="sm" font-thin mb-2> | ||||||
The latest test that might've caused the error is <span font-bold>{{ e.VITEST_TEST_NAME }}</span>. It might mean one of the following:<br> | ||||||
<ul> | ||||||
<li> | ||||||
The error was thrown, while Vitest was running this test. | ||||||
</li> | ||||||
<li> | ||||||
This was the last recorded test before the error was thrown, if error originated after test finished its execution. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spiroka did some rewording here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dammy001 Thanks! I will update this text for the CLI as well then. |
||||||
</li> | ||||||
</ul> | ||||||
</p> | ||||||
<p v-if="e.VITEST_AFTER_ENV_TEARDOWN" text="sm" font-thin> | ||||||
This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:<br> | ||||||
<ul> | ||||||
<li> | ||||||
Cancel timeouts using clearTimeout and clearInterval. | ||||||
</li> | ||||||
<li> | ||||||
Wait for promises to resolve using the await keyword. | ||||||
</li> | ||||||
</ul> | ||||||
</p> | ||||||
</template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't import from
vitest/
in UI package. Only relative paths are allowed there. This particular function can just be inlined