-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-resolveSnapshotPath-context
- Loading branch information
Showing
12 changed files
with
111 additions
and
29 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
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
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"))) |
3 changes: 3 additions & 0 deletions
3
test/config/fixtures/unhandled-rejections/setup-unhandled-rejections.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,3 @@ | ||
export function setup() { | ||
void new Promise((_, reject) => reject(new Error('intentional unhandled rejection'))) | ||
} |
4 changes: 4 additions & 0 deletions
4
test/config/fixtures/unhandled-rejections/tests/example.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,4 @@ | ||
import { test } from "vitest" | ||
|
||
test("Some test", () => {}) | ||
|
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') | ||
}) |
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,16 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { runVitest } from '../../test-utils' | ||
|
||
test('unhandled rejections of main thread are reported even when no reporter is used', async () => { | ||
const { stderr, exitCode } = await runVitest({ | ||
root: 'fixtures/unhandled-rejections', | ||
globalSetup: ['setup-unhandled-rejections.ts'], | ||
reporters: [{ onInit: () => {} }], | ||
}) | ||
|
||
expect(exitCode).toBe(1) | ||
expect(stderr).toContain('Unhandled Rejection') | ||
expect(stderr).toContain('Error: intentional unhandled rejection') | ||
expect(stderr).toContain('setup-unhandled-rejections.ts:2:42') | ||
}) |