Skip to content

Commit 15aa015

Browse files
authoredJan 16, 2023
fix: always show filename for unhandled errors (#2689)
* chore: fix typo * fix: always show filename for unhandled errors
1 parent 019a6d5 commit 15aa015

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎packages/vitest/src/node/error.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
6969
const testPath = (e as any).VITEST_TEST_PATH
7070
const testName = (e as any).VITEST_TEST_NAME
7171
// testName has testPath inside
72-
if (testPath && !testName)
72+
if (testPath)
7373
ctx.logger.error(c.red(`This error originated in "${c.bold(testPath)}" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.`))
7474
if (testName) {
75-
ctx.logger.error(c.red(`The latest test that migh've cause the error is "${c.bold(testName)}". It might mean one of the following:`
75+
ctx.logger.error(c.red(`The latest test that might've caused the error is "${c.bold(testName)}". It might mean one of the following:`
7676
+ '\n- The error was thrown, while Vitest was running this test.'
7777
+ '\n- This was the last recorder test before the error was thrown, if error originated after test finished its execution.'))
7878
}
@@ -84,7 +84,7 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
8484

8585
handleImportOutsideModuleError(e.stack || e.stackStr || '', ctx)
8686

87-
// Eg. AssertionError from assert does not set showDiff but has both actual and expected properties
87+
// E.g. AssertionError from assert does not set showDiff but has both actual and expected properties
8888
if (e.showDiff || (e.showDiff === undefined && e.actual && e.expected)) {
8989
displayDiff(stringify(e.actual), stringify(e.expected), ctx.logger.console, {
9090
outputTruncateLength: ctx.config.outputTruncateLength,

0 commit comments

Comments
 (0)
Please sign in to comment.