-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Describe the bug
reproduction: https://stackblitz.com/edit/vitest-dev-vitest-3rp6jxtm?file=test%2Frepro.test.ts
For example, test cases below makes terminal look stuck with Tests 0 passed (1000) for a long time:
import { test } from 'vitest';
test.for([...Array(1000)].map((_, i) => i))('test %s', async () => {
await new Promise((r) => setTimeout(r, 5));
});❯ npm run test
...
❯ test/repro.test.ts 0/1000
Test Files 0 passed (1)
Tests 0 passed (1000)
Start at 10:55:28
Duration 9.90s
Perhaps, this can be improved by throttling updateTask instead of debouncing each 10ms entirely:
vitest/packages/runner/src/run.ts
Lines 180 to 190 in 0c2924b
| export function updateTask(event: TaskUpdateEvent, task: Task, runner: VitestRunner): void { | |
| eventsPacks.push([task.id, event]) | |
| packs.set(task.id, [task.result, task.meta]) | |
| const { clearTimeout, setTimeout } = getSafeTimers() | |
| clearTimeout(updateTimer) | |
| updateTimer = setTimeout(() => { | |
| previousUpdate = sendTasksUpdate(runner) | |
| }, 10) | |
| } |
Real use case is here https://github.com/oxc-project/oxc/blob/e637e2edcf365f5c3d24344ee14a50d6b036b5bc/napi/parser/test/parse-raw.test.ts#L98 and I was confused by the test progress:
$ pnpm -C napi/parser test-node parse-raw -t test262
> oxc-parser@0.60.0 test-node /home/hiroshi/code/others/oxc/napi/parser
> vitest --dir ./test parse-raw -t test262
DEV v3.0.8 /home/hiroshi/code/others/oxc/napi/parser
❯ test/parse-raw.test.ts 0/44008
Test Files 0 passed (1)
Tests 0 passed (44008)
Start at 10:49:12
Duration 2.98s
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-3rp6jxtm?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.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@vitest/ui: latest => 3.0.9
vite: latest => 6.2.2
vitest: latest => 3.0.9Used 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