-
-
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:
dangerouslyIgnoreUnhandledErrors
without base reporter
- Loading branch information
1 parent
47d7c0a
commit 473d377
Showing
5 changed files
with
56 additions
and
7 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
7 changes: 7 additions & 0 deletions
7
test/config/fixtures/dangerously-ignore-unhandled-errors/tests/throw-errors.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,7 @@ | ||
import { test } from "vitest" | ||
|
||
test("Some test", () => { | ||
// | ||
}) | ||
|
||
new Promise((_, reject) => reject(new Error("intentional unhandled error"))) |
35 changes: 35 additions & 0 deletions
35
test/config/test/dangerously-ignore-unhandled-errors.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,35 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { runVitest } from '../../test-utils' | ||
|
||
test('{ dangerouslyIgnoreUnhandledErrors: true }', async () => { | ||
const { stderr, stdout, exitCode } = await runVitest({ | ||
root: 'fixtures/dangerously-ignore-unhandled-errors', | ||
dangerouslyIgnoreUnhandledErrors: true, | ||
}) | ||
|
||
expect(exitCode).toBe(0) | ||
expect(stdout).toMatch('Vitest caught 1 unhandled error during the test run') | ||
expect(stderr).toMatch('Error: intentional unhandled error') | ||
}) | ||
|
||
test('{ dangerouslyIgnoreUnhandledErrors: true } without reporter', async () => { | ||
const { exitCode } = await runVitest({ | ||
root: 'fixtures/dangerously-ignore-unhandled-errors', | ||
dangerouslyIgnoreUnhandledErrors: true, | ||
reporters: [{ onInit: () => {} }], | ||
}) | ||
|
||
expect(exitCode).toBe(0) | ||
}) | ||
|
||
test('{ dangerouslyIgnoreUnhandledErrors: false }', async () => { | ||
const { stderr, stdout, exitCode } = await runVitest({ | ||
root: 'fixtures/dangerously-ignore-unhandled-errors', | ||
dangerouslyIgnoreUnhandledErrors: false, | ||
}) | ||
|
||
expect(exitCode).toBe(1) | ||
expect(stdout).toMatch('Vitest caught 1 unhandled error during the test run') | ||
expect(stderr).toMatch('Error: intentional unhandled error') | ||
}) |