Skip to content

Commit

Permalink
docs: updated "vi.mock" documentation link (#3198)
Browse files Browse the repository at this point in the history
  • Loading branch information
oriolgm committed Apr 15, 2023
1 parent cbb593a commit 31f835f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/mocks/test/error-mock.spec.ts
Expand Up @@ -4,5 +4,5 @@ vi.mock('../src/default', () => {

test('when using top level variable, gives helpful message', async () => {
await expect(() => import('../src/default').then(m => m.default)).rejects
.toThrowErrorMatchingInlineSnapshot('"[vitest] There was an error when mocking a module. If you are using \\"vi.mock\\" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/#vi-mock"')
.toThrowErrorMatchingInlineSnapshot('"[vitest] There was an error when mocking a module. If you are using \\"vi.mock\\" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock"')
})
2 changes: 1 addition & 1 deletion packages/vitest/src/runtime/mocker.ts
Expand Up @@ -116,7 +116,7 @@ export class VitestMocker {
const vitestError = new Error(
'[vitest] There was an error when mocking a module. '
+ 'If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. '
+ 'Read more: https://vitest.dev/api/#vi-mock')
+ 'Read more: https://vitest.dev/api/vi.html#vi-mock')
vitestError.cause = err
throw vitestError
}
Expand Down

0 comments on commit 31f835f

Please sign in to comment.