-
Notifications
You must be signed in to change notification settings - Fork 11
Fix Jest test mocks #58
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
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
Hello, My team is facing issue that this PR would solve. Thanks for providing it and I hope this will be soon taken into account. |
There was a problem hiding this 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 a CommonJS entry point to the package exports so Jest can correctly mock the library.
- Adds a
require
mapping under the root export to point to the CJS build. - Ensures Jest can resolve the module when running tests.
"react-native-device-info": { | ||
"optional": true | ||
} | ||
"./manual": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ./manual
export block currently only defines types
. You should add a require
mapping (e.g., "require": "./dist/manualIndex.js"
) so Jest can resolve the CommonJS path for the manual entry as well.
Copilot uses AI. Check for mistakes.
Issue
Version
4.3.0
changed how files were exported in thepackage.json
as you can see in this commit. If you were mocking the library on Jest so tests could pass, the new configuration wasn't allowing Jest to find the package to be mocked.Solution
Adding
require
to to each of theexports
solves the issue and allows Jest to work again.