-
-
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.
feat(vitest): add onTestFinished hook (#5128)
- Loading branch information
1 parent
2085131
commit 6f5b42b
Showing
8 changed files
with
176 additions
and
5 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
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,43 @@ | ||
import { expect, it, onTestFinished } from 'vitest' | ||
|
||
const collected: any[] = [] | ||
|
||
it('on-finished regular', () => { | ||
collected.push(1) | ||
onTestFinished(() => { | ||
collected.push(3) | ||
}) | ||
collected.push(2) | ||
}) | ||
|
||
it('on-finished context', (t) => { | ||
collected.push(4) | ||
t.onTestFinished(() => { | ||
collected.push(6) | ||
}) | ||
collected.push(5) | ||
}) | ||
|
||
it.fails('failed finish', () => { | ||
collected.push(7) | ||
onTestFinished(() => { | ||
collected.push(9) | ||
}) | ||
collected.push(8) | ||
expect.fail('failed') | ||
collected.push(null) | ||
}) | ||
|
||
it.fails('failed finish context', (t) => { | ||
collected.push(10) | ||
t.onTestFinished(() => { | ||
collected.push(12) | ||
}) | ||
collected.push(11) | ||
expect.fail('failed') | ||
collected.push(null) | ||
}) | ||
|
||
it('after', () => { | ||
expect(collected).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) | ||
}) |