Clear the act() and ts-jest deprecation warnings from test runs - #258
Merged
Conversation
SaveAsProjectModal's "prefills the name and description fields" test rendered and asserted synchronously, so useProjectsForSource's mocked load resolved after the test body finished and fired two unwrapped state updates. Await the first assertion so the load settles first. Move ts-jest's deprecated isolatedModules option under tsconfig rather than into tsconfig.json, keeping it scoped to Jest so lint:typecheck retains its cross-file type-check.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
imnasnainaec
approved these changes
Aug 20, 2026
imnasnainaec
left a comment
Contributor
There was a problem hiding this comment.
@imnasnainaec reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).
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.
Test runs emitted two classes of warning. Neither failed the build, but both are noise that trains readers to skim CI output, and one is on a path to breaking.
act()warningReact's test renderer warns when a component's state updates outside an
act()scope, because updates applied after a test's assertions can't be observed by them — the test passes on a render that was already stale.@testing-library/reactwrapsrenderanduserEventinact()automatically, so the warning surfaces only when an update lands outside anything the library wrapped.SaveAsProjectModal.test.tsx's "prefills the name and description fields from the defaults" was the only test in the file that rendered and asserted entirely synchronously. Its siblings allawaitsomething (waitFororuserEvent), which incidentally holds anact()scope open long enough foruseProjectsForSource's mockedsendCommandto settle inside it. This one didn't, so the load resolved after the test body finished and fired two state updates —setProjectsandsetIsLoading— with noact()scope active. Hence exactly two warnings.Fixed by awaiting the first assertion so the load settles before the test ends.
Considered mocking the hook instead and rejected it:
useProjectsForSourcehas no dedicated test file, and its 100% coverage comes entirely from the two modal tests exercising it for real. Mocking would delete that coverage and require writing a replacement hook test — significant work to fix what oneawaitfixes. Every hook this repo does mock has its own test file; this one doesn't fit the pattern.ts-jest deprecation
Moved to
tsconfig: { isolatedModules: true }— inline compiler options on the transform. Deliberately not hoisted intotsconfig.jsonas the warning text suggests, since that would scope the flag beyond Jest and costlint:typecheckits cross-file type-check.Verified the transpile-only behavior that
jest.config.tsdepends on still holds: ran the suite from a git worktree, wheretypeRootspaths like../paranext-core/libdon't resolve, and confirmed no TS2307 cascade.Verification
npx jest --ci— 63 suites, 1784 tests passing, 0 act warnings, 0 ts-jest warnings.npm run lintclean.Note that these warnings only surface when stdout is a TTY or under
--ci; Jest suppresses per-suite console blocks when output is piped, which is why they're easy to miss locally.This change is