-
-
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: handle errors thrown in fixtures
- Loading branch information
1 parent
9734e81
commit f6844ad
Showing
3 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { afterEach, beforeEach, describe, expectTypeOf, test } from 'vitest' | ||
|
||
describe('error thrown in beforeEach fixtures', () => { | ||
const myTest = test.extend<{ a: never }>({ | ||
a: async () => { | ||
throw new Error('Error thrown in beforeEach fixture') | ||
}, | ||
}) | ||
|
||
// eslint-disable-next-line unused-imports/no-unused-vars | ||
beforeEach<{ a: never }>(({ a }) => {}) | ||
|
||
myTest('error is handled', () => {}) | ||
}) | ||
|
||
describe('error thrown in afterEach fixtures', () => { | ||
const myTest = test.extend<{ a: never }>({ | ||
a: async () => { | ||
throw new Error('Error thrown in afterEach fixture') | ||
}, | ||
}) | ||
|
||
// eslint-disable-next-line unused-imports/no-unused-vars | ||
afterEach<{ a: never }>(({ a }) => {}) | ||
|
||
myTest('fixture errors', () => { | ||
expectTypeOf(1).toEqualTypeOf<number>() | ||
}) | ||
}) | ||
|
||
describe('error thrown in test fixtures', () => { | ||
const myTest = test.extend<{ a: never }>({ | ||
a: async () => { | ||
throw new Error('Error thrown in test fixture') | ||
}, | ||
}) | ||
|
||
// eslint-disable-next-line unused-imports/no-unused-vars | ||
myTest('fixture errors', ({ a }) => {}) | ||
}) |
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