Merged
Conversation
a11f3e2 to
41d3dcd
Compare
DeJeune
approved these changes
Feb 11, 2026
e3070fe to
fdfff0e
Compare
Move generateToolEnvironment import below test framework and type imports to satisfy linting/order rules and keep import groups consistent. This fixes an import-order warning in the index.test.ts file and preserves the mock setup for CodeToolsPage.
fdfff0e to
4889d07
Compare
EurFelux
approved these changes
Feb 12, 2026
Collaborator
EurFelux
left a comment
There was a problem hiding this comment.
Code Review: fix(test): codetool test timeout
Overview
This PR replaces dynamic await import('../index') calls within each test case with a single static import { generateToolEnvironment } from '../index' at the top of the file. This resolves a test timeout issue (10s → 4ms) and eliminates an import-order lint warning.
What's Good
- Root cause is correct: Dynamic imports inside test cases cause Vitest to re-evaluate the module (and all its transitive dependencies) on every invocation, which explains the timeout. A static import lets Vitest resolve the module once and cache it.
- Mock setup remains valid: All
vi.mock()calls are still hoisted above the static import by Vitest's transform, so mock isolation is preserved. - Tests become synchronous: Removing
async/awaitfrom test cases that don't need it is a clean improvement — it simplifies the test signatures and makes failures easier to diagnose. - CI passes: All checks (basic-checks, general-test, render-test) are green.
- Minimal diff: +11 / -17 lines — focused and easy to review.
Minor Observations
- Comment wording change (line 5): the original "which is the default export" reads slightly better grammatically than "which is default export", but this is purely cosmetic and not worth blocking.
Risk Assessment
- Low risk — this is a test-only change with no impact on production code.
- The mock hoisting behavior in Vitest is well-documented and reliable for static imports, so this pattern is safe.
Verdict
Clean, focused fix that correctly addresses the root cause. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
After this PR:
Fixes #
Why we need it and why it was done in this way
The dynamic import caused test execution to hang/time out. Using a static import and adjusting import order both fixes the timeout and satisfies linting rules while keeping the existing mock setup intact. The test now only cost 4ms compared to 10s before modify.
Checklist
Release note