-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
When bench is invoked at the top of the module his results are displayed twice.
Wrapping the bench call in a describe doesn't duplicate the results.
sum-without-describe.bench.ts
import { bench } from "vitest";
bench("sum", () => {
1 + 1;
});sum-with-describe.bench.ts
import { bench, describe } from "vitest";
describe("sum", () => {
bench("a", () => {
1 + 1;
});
});Result
✓ tests/sum-with-describe.bench.ts > sum 5789ms
name hz min max mean p75 p99 p995 p999 rme samples
· a 48,128,806.17 0.0000 0.0327 0.0000 0.0000 0.0000 0.0000 0.0001 ±0.05% 24064404
✓ tests/sum-without-describe.bench.ts 5748ms
name hz min max mean p75 p99 p995 p999 rme samples
· sum 48,075,917.04 0.0000 0.0334 0.0000 0.0000 0.0000 0.0000 0.0001 ±0.05% 24037959
✓ tests/sum-without-describe.bench.ts 5748ms
name hz min max mean p75 p99 p995 p999 rme samples
· sum 48,075,917.04 0.0000 0.0334 0.0000 0.0000 0.0000 0.0000 0.0001 ±0.05% 24037959
Reproduction
Code: https://github.com/marcalexiei/vitest-bench-playground
GitHub actions: https://github.com/marcalexiei/vitest-bench-playground/actions/runs/22277251116/job/64441360076
System Info
System:
OS: macOS 26.3
CPU: (8) arm64 Apple M3
Memory: 139.19 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.12.0 - /.nvm/versions/node/v24.12.0/bin/node
npm: 11.6.2 - /.nvm/versions/node/v24.12.0/bin/npm
pnpm: 10.28.2 - /.nvm/versions/node/v24.12.0/bin/pnpm
Browsers:
Chrome: 144.0.7559.133
Safari: 26.3
npmPackages:
vitest: 4.0.18 => 4.0.18Used Package Manager
pnpm
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)