docs: add Jest troubleshooting note for @react-three/cannon#450
docs: add Jest troubleshooting note for @react-three/cannon#450aman010mishra wants to merge 2 commits intopmndrs:masterfrom
Conversation
Added testing guidelines for Jest related to @react-three/cannon, including configuration tips and approaches for unit testing components that use physics hooks.
Removed duplicate information about testing with Jest and streamlined the section for clarity.
|
@aman010mishra is attempting to deploy a commit to the Poimandres Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds README guidance to help users troubleshoot Jest module-resolution errors when importing @react-three/cannon, in response to Issue #419.
Changes:
- Introduces a “Testing with Jest” troubleshooting section in the package README
- Suggests common approaches (ESM-aware Jest config, mocking, and test layering) to mitigate import-related failures
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ### Testing with Jest | ||
|
|
||
| If Jest reports that it cannot find `@react-three/cannon`, the problem is usually related to the test environment rather than the runtime package itself. | ||
|
|
||
| Because `@react-three/cannon` is commonly used in modern React/ESM setups, some Jest configurations may need additional module resolution or transform settings. If you are unit testing components that import physics hooks, consider one of these approaches: |
There was a problem hiding this comment.
The heading level for "Testing with Jest" breaks the FAQ structure: it’s currently an H3 (###) inside the "### FAQ" section, while the surrounding FAQ entries (e.g., "Broadphases", "Types") are H4 (####). As written, this makes "Types" appear as a subsection of "Testing with Jest" instead of a sibling FAQ item. Consider changing this heading to H4 (####) to keep the hierarchy consistent.
| - configure Jest to handle ESM dependencies used by your React/Three stack | ||
| - mock `@react-three/cannon` in tests that do not need real physics behavior | ||
| - keep physics integration in higher-level tests and isolate pure logic into testable helper functions |
There was a problem hiding this comment.
The bullet list items under the new Jest section start with lowercase verbs ("configure", "mock", "keep") while other bullets in this FAQ read like sentences starting with capitals (e.g., "NaiveBroadphase...", "A dynamic body..."). Consider capitalizing these list items (and optionally adding consistent punctuation) for readability and consistency within the README.
| - configure Jest to handle ESM dependencies used by your React/Three stack | |
| - mock `@react-three/cannon` in tests that do not need real physics behavior | |
| - keep physics integration in higher-level tests and isolate pure logic into testable helper functions | |
| - Configure Jest to handle ESM dependencies used by your React/Three stack | |
| - Mock `@react-three/cannon` in tests that do not need real physics behavior | |
| - Keep physics integration in higher-level tests and isolate pure logic into testable helper functions |
Summary
Adds a small README note for users who hit Jest module resolution issues with @react-three/cannon.
Problem
Issue #419 reports that Jest cannot find the @react-three/cannon module.
Changes
Notes
This PR is docs-only and does not change runtime behavior.