| 313 | } |
| 314 | |
| 315 | function createHelpfulError(cause: Error) { |
| 316 | const error = new Error( |
| 317 | '[vitest] There was an error when mocking a module. ' |
| 318 | + '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. ' |
| 319 | + 'Read more: https://vitest.dev/api/vi.html#vi-mock', |
| 320 | ) |
| 321 | error.cause = cause |
| 322 | return error |
| 323 | } |
| 324 | |
| 325 | function assertValidExports(raw: string, exports: any) { |
| 326 | if (exports === null || typeof exports !== 'object' || Array.isArray(exports)) { |