Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): react-router should work with jest out of the box #30487

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

ndcunningham
Copy link
Contributor

Jest should be compatible with react-router out of the box.

Current Behavior

Currently, there are two issues when using jest with react-router out of the box

  1. Test files are not included from tsconfig
  2. While running the test jsdom is missing Node's TextEncoder and TextDecoder so compilation fails.

Expected Behavior

Running a test should work without issues when you create a react-router app with Jest.

Related Issue(s)

Fixes #30387

@ndcunningham ndcunningham self-assigned this Mar 24, 2025
@ndcunningham ndcunningham requested review from a team as code owners March 24, 2025 17:50
Copy link

vercel bot commented Mar 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Mar 26, 2025 2:14pm

@ndcunningham ndcunningham force-pushed the fix/react-router-jest branch from 281a10e to a727025 Compare March 24, 2025 17:50
Copy link

nx-cloud bot commented Mar 24, 2025

View your CI Pipeline Execution ↗ for commit dadb3a7.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 39m 37s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 17s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=9cd75... ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗
nx documentation ✅ Succeeded 1m 28s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-26 14:57:14 UTC

Copy link

nx-cloud bot commented Mar 24, 2025

View your CI Pipeline Execution ↗ for commit a727025.


☁️ Nx Cloud last updated this comment at 2025-03-24 17:51:33 UTC

@ndcunningham ndcunningham force-pushed the fix/react-router-jest branch 2 times, most recently from e99d008 to 9762522 Compare March 24, 2025 19:16
@ndcunningham ndcunningham requested review from a team as code owners March 24, 2025 19:16
@ndcunningham ndcunningham force-pushed the fix/react-router-jest branch from 9762522 to 37cc2cc Compare March 24, 2025 20:37
Copy link
Contributor

@Coly010 Coly010 left a comment

Choose a reason for hiding this comment

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

  • add an e2e that runs typecheck
  • In the e2e that is checking that the tests pass, also check that the number of passing test suites matches the expected number

Copy link
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

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

LGTM. I left a couple of recommendations to reduce some overhead in the e2e tests.

@ndcunningham ndcunningham force-pushed the fix/react-router-jest branch from 7e2bd81 to 59907f3 Compare March 26, 2025 14:10
@ndcunningham ndcunningham force-pushed the fix/react-router-jest branch from 59907f3 to dadb3a7 Compare March 26, 2025 14:12
@ndcunningham ndcunningham merged commit 1a235d7 into master Mar 26, 2025
12 checks passed
@ndcunningham ndcunningham deleted the fix/react-router-jest branch March 26, 2025 16:44
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.

Apps generated on a fresh workspace with react-router have typecheck and tsconfig issue
4 participants