|
| 1 | +import { expect, test } from 'vitest' |
| 2 | + |
| 3 | +import { runVitest } from '../../test-utils' |
| 4 | + |
| 5 | +test('{ dangerouslyIgnoreUnhandledErrors: true }', async () => { |
| 6 | + const { stderr, stdout, exitCode } = await runVitest({ |
| 7 | + root: 'fixtures/dangerously-ignore-unhandled-errors', |
| 8 | + dangerouslyIgnoreUnhandledErrors: true, |
| 9 | + }) |
| 10 | + |
| 11 | + expect(exitCode).toBe(0) |
| 12 | + expect(stdout).toMatch('Vitest caught 1 unhandled error during the test run') |
| 13 | + expect(stderr).toMatch('Error: intentional unhandled error') |
| 14 | +}) |
| 15 | + |
| 16 | +test('{ dangerouslyIgnoreUnhandledErrors: true } without reporter', async () => { |
| 17 | + const { exitCode } = await runVitest({ |
| 18 | + root: 'fixtures/dangerously-ignore-unhandled-errors', |
| 19 | + dangerouslyIgnoreUnhandledErrors: true, |
| 20 | + reporters: [{ onInit: () => {} }], |
| 21 | + }) |
| 22 | + |
| 23 | + expect(exitCode).toBe(0) |
| 24 | +}) |
| 25 | + |
| 26 | +test('{ dangerouslyIgnoreUnhandledErrors: false }', async () => { |
| 27 | + const { stderr, stdout, exitCode } = await runVitest({ |
| 28 | + root: 'fixtures/dangerously-ignore-unhandled-errors', |
| 29 | + dangerouslyIgnoreUnhandledErrors: false, |
| 30 | + }) |
| 31 | + |
| 32 | + expect(exitCode).toBe(1) |
| 33 | + expect(stdout).toMatch('Vitest caught 1 unhandled error during the test run') |
| 34 | + expect(stderr).toMatch('Error: intentional unhandled error') |
| 35 | +}) |
0 commit comments