-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Labels
p2-to-be-discussedEnhancement under consideration (priority)Enhancement under consideration (priority)pending triage
Description
Describe the bug
Related
- Reporter error is silenced when
--merge-reports#9642 - fix: don't silence reporter errors from test runtime events handler in normal run and --merge-reports #9727 (comment)
Not only --merge-reports, but normal test run also silences reporter errors that are thrown during test runtime event such as onUserConsoleLog.
- repro.test.ts
import { test } from 'vitest';
test('foo', () => {
console.log('test-crash');
});- vitest.config.ts
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: [
'default',
{
onUserConsoleLog(log) {
if (log.content.includes('test-crash')) {
console.log('throwing an error from Reporter.onUserConsoleLog!');
throw new Error('reporter error during onUserConsoleLog');
}
},
},
],
},
});Test finishes with no errors:
❯ vitest --run
RUN v4.1.0-beta.4 /home/projects/vitest-dev-vitest-9qgrszam
stdout | test/repro.test.ts > foo
test-crash
throwing an error from Reporter.onUserConsoleLog!
✓ test/repro.test.ts (1 test) 3ms
✓ foo 2ms
Test Files 1 passed (1)
Tests 1 passed (1)
Start at 11:59:16
Duration 621ms (transform 37ms, setup 0ms, import 52ms, tests 3ms, environment 0ms)
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-9qgrszam?file=vitest.config.ts
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vitest: beta => 4.1.0-beta.4Used 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p2-to-be-discussedEnhancement under consideration (priority)Enhancement under consideration (priority)pending triage
Type
Projects
Status
P2 - 3