Skip to content

fix(vitest-plugin): stop calling the root suite's beforeAll/afterAll twice - #108

Open
prisis wants to merge 1 commit into
CodSpeedHQ:mainfrom
prisis:fix/vitest-root-suite-hooks
Open

prisis wants to merge 1 commit into
CodSpeedHQ:mainfrom
prisis:fix/vitest-root-suite-hooks

Conversation

@prisis

@prisis prisis commented Oct 26, 2026

Copy link
Copy Markdown

Fixes #106.

Vitest's runner calls the file suite's beforeAll/afterAll itself, around runner.runSuite(), on both Vitest 3 and 4. The analysis runner called them again on the same root suite, so file-level setup ran twice: once outside the CodSpeed run and once inside it.

runAnalysisBenchmarkSuite now skips the hook calls for the root suite. Nested suites are only reached through this runner, so their hooks are still called, once each.

Test

should leave the root suite's beforeAll/afterAll to vitest registers both hooks on a root suite and a nested suite, then asserts that only the nested suite's hooks run, once each. It fails on main (the root hooks show up) and passes with this change. lint, typecheck, format and the plugin's 15 tests pass.

🤖 Generated with Claude Code

…twice

Vitest's runner calls the file suite's beforeAll/afterAll itself around
runner.runSuite(), on Vitest 3 and 4. The analysis runner called them
again on the same root suite, so file-level setup ran twice: once outside
the CodSpeed run and once inside it. Nested suites are only reached
through the runner, so their hooks are still called, once each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

The analysis runner now leaves the root suite’s beforeAll and afterAll to Vitest.

  • The analysis runner leaves file-level hooks to Vitest.

Reviews (1) · Last reviewed commit: "fix(vitest-plugin): stop calling the roo..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vitest-plugin: root-level beforeAll/afterAll run twice in analysis mode

1 participant