-
-
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(vitest): show correct error when vi.hoisted is used inside vi.moc…
…k and the other way around (#4916)
- Loading branch information
1 parent
0e77e69
commit c4eacbb
Showing
6 changed files
with
210 additions
and
9 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,78 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 1`] = `"Cannot call vi.hoisted() inside vi.mock(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 2`] = ` | ||
" 3| | ||
4| vi.mock('./mocked', () => { | ||
5| const variable = vi.hoisted(() => 1) | ||
| ^ | ||
6| console.log(variable) | ||
7| })" | ||
`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 3`] = `"Cannot call vi.hoisted() inside vi.mock(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 4`] = ` | ||
" 3| | ||
4| vi.mock('./mocked', async () => { | ||
5| await vi.hoisted(() => 1) | ||
| ^ | ||
6| }) | ||
7| " | ||
`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 5`] = `"Cannot call vi.hoisted() inside vi.mock(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 6`] = ` | ||
" 3| | ||
4| vi.mock('./mocked', async () => { | ||
5| const variable = await vi.hoisted(() => 1) | ||
| ^ | ||
6| }) | ||
7| " | ||
`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 7`] = `"Cannot call vi.mock() inside vi.hoisted(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 8`] = ` | ||
" 3| | ||
4| vi.hoisted(() => { | ||
5| vi.mock('./mocked') | ||
| ^ | ||
6| }) | ||
7| " | ||
`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 9`] = `"Cannot call vi.mock() inside vi.hoisted(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 10`] = ` | ||
" 3| | ||
4| const values = vi.hoisted(() => { | ||
5| vi.mock('./mocked') | ||
| ^ | ||
6| }) | ||
7| " | ||
`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 11`] = `"Cannot call vi.mock() inside vi.hoisted(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 12`] = ` | ||
" 3| | ||
4| await vi.hoisted(async () => { | ||
5| vi.mock('./mocked') | ||
| ^ | ||
6| }) | ||
7| " | ||
`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 13`] = `"Cannot call vi.mock() inside vi.hoisted(): both methods are hoisted to the top of the file and not actually called inside each other."`; | ||
|
||
exports[`throws an error when nodes are incompatible > correctly throws an error 14`] = ` | ||
" 3| | ||
4| const values = await vi.hoisted(async () => { | ||
5| vi.mock('./mocked') | ||
| ^ | ||
6| }) | ||
7| " | ||
`; |
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