-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
I wasn't sure if this is an intended usage of vi.hoisted, but I suppose SyntaxError is not meant to surface to users regardless.
For this test file input:
import { test, vi } from 'vitest';
test('ok', () => {});
vi.mock('./dummy.ts');
await vi.hoisted(async () => {});VITE_NODE_DEBUG_DUMP=1 vitest shows this transformed output:
const { test, vi } = await __vite_ssr_dynamic_import__('vitest')
vi.mock("./dummy.ts");
vi.hoisted(async () => {
});
test("ok", () => {
});
awaitwith the test error:
FAIL test/repro.test.ts [ test/repro.test.ts ]
SyntaxError: Unexpected token '}'
❯ __global_eval__ ../../../blitz.f7aa08df.js:1:263
❯ _0x5dcd1e ../../../blitz.f7aa08df.js:352:200671
❯ Script.runInContext ../../../blitz.f7aa08df.js:352:199875
❯ Script.runInThisContext node:vm:74:1318
❯ Object.runInThisContext node:vm:74:3926
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-gms3di?file=test%2Frepro.test.ts
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.4.2 - /usr/local/bin/npm
pnpm: 8.14.0 - /usr/local/bin/pnpm
npmPackages:
@vitest/ui: latest => 1.1.3
vite: latest => 5.0.11
vitest: latest => 1.1.3Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)