Skip to content

docs: add Jest troubleshooting note for @react-three/cannon#450

Open
aman010mishra wants to merge 2 commits intopmndrs:masterfrom
aman010mishra:master
Open

docs: add Jest troubleshooting note for @react-three/cannon#450
aman010mishra wants to merge 2 commits intopmndrs:masterfrom
aman010mishra:master

Conversation

@aman010mishra
Copy link
Copy Markdown

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

  • Added a short "Testing with Jest" section to the package README
  • Included practical guidance for common test setup approaches

Notes

This PR is docs-only and does not change runtime behavior.

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.
Copilot AI review requested due to automatic review settings April 12, 2026 09:48
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 12, 2026

@aman010mishra is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +594 to +598
### 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:
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +600 to +602
- 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
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
- 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

Copilot uses AI. Check for mistakes.
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.

2 participants