fix: eliminate Vite config and React act() warnings in tests - #1068
Open
EhabY wants to merge 1 commit into
Open
Conversation
- Rename vitest.config.ts to .mts and replace __dirname with import.meta.dirname to resolve the Vite native configLoader warning about ESM syntax in a CJS-loaded file. - Call RTL cleanup() before resetting the DOM attribute in afterEach so the MutationObserver callback doesn't fire a state update on a still-mounted component, which caused 'not wrapped in act()' warnings.
EhabY
force-pushed
the
fix/test-warnings
branch
from
August 6, 2026 00:16
0c982ba to
47b3b48
Compare
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
pnpm testprints two categories of warnings:Vite config loader warning (3x):
vitest.config.tsuses ESM syntax but the rootpackage.jsonhas"type": "commonjs", so Vite loads it as CJS and warns about the upcomingconfigLoader: "native"default.React act() warnings (4x in
useVscodeTheme.test.ts): TheafterEachcleanup mutates the DOM attribute while the previous test's hook is still mounted (RTL auto-cleanup runs after user-registeredafterEach). TheMutationObservercallback fires in a microtask and triggers a state update outsideact().Changes
Rename
vitest.config.ts→vitest.config.mtsand replace__dirnamewithimport.meta.dirname. This makes the config unambiguously ESM, silencing the Vite warning.Add explicit
unmount()calls in eachuseVscodeThemetest so the hook is torn down before theafterEachattribute cleanup fires. TheMutationObservercallback then has no mounted component to update, eliminating the act() warnings.Verification
pnpm typecheckandpnpm format:checkpass.pnpm lintcrashes with a core dump onmaintoo (pre-existing environment issue, not caused by this change).Generated by Coder Agents