Skip to content

Clear the act() and ts-jest deprecation warnings from test runs - #258

Merged
alex-rawlings-yyc merged 1 commit into
mainfrom
fix-jest-act-and-ts-jest-warnings
Aug 20, 2026
Merged

Clear the act() and ts-jest deprecation warnings from test runs#258
alex-rawlings-yyc merged 1 commit into
mainfrom
fix-jest-act-and-ts-jest-warnings

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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() warning

React'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/react wraps render and userEvent in act() 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 all await something (waitFor or userEvent), which incidentally holds an act() scope open long enough for useProjectsForSource's mocked sendCommand to settle inside it. This one didn't, so the load resolved after the test body finished and fired two state updates — setProjects and setIsLoading — with no act() 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: useProjectsForSource has 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 one await fixes. Every hook this repo does mock has its own test file; this one doesn't fit the pattern.

ts-jest deprecation

The "ts-jest" config option "isolatedModules" is deprecated and will be removed in v30.0.0

Moved to tsconfig: { isolatedModules: true } — inline compiler options on the transform. Deliberately not hoisted into tsconfig.json as the warning text suggests, since that would scope the flag beyond Jest and cost lint:typecheck its cross-file type-check.

Verified the transpile-only behavior that jest.config.ts depends on still holds: ran the suite from a git worktree, where typeRoots paths like ../paranext-core/lib don'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 lint clean.

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 Reviewable

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.
@alex-rawlings-yyc alex-rawlings-yyc self-assigned this Aug 20, 2026
@alex-rawlings-yyc alex-rawlings-yyc added the up next Auto adds an issue to the PT Lexical Extensions project label Aug 20, 2026
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 02d8d0de-19d8-4968-b634-6a8090bc0db7


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@imnasnainaec imnasnainaec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imnasnainaec reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

@alex-rawlings-yyc
alex-rawlings-yyc merged commit c754be0 into main Aug 20, 2026
10 checks passed
@alex-rawlings-yyc
alex-rawlings-yyc deleted the fix-jest-act-and-ts-jest-warnings branch August 20, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

up next Auto adds an issue to the PT Lexical Extensions project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants