mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix Image Jest mock after extraction to separate package (#55710)
Summary: Transition to `react-native/jest-preset` broke the `Image` mock, as it started to render unmocked `RCTImageView` instead of mocked `Image`. This is result of differences between node resolution that takes into account platform-specific imports (`Image.ios.js`) vs Jest mocking `Image.js`. This works fine in the files are in the same package, but broke when doing deep imports from separate package. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [INTERNAL] [FIXED] Fix `Image` Jest mock after extraction to `react-native/jest-preset` Pull Request resolved: https://github.com/facebook/react-native/pull/55710 Test Plan: Added automated tests to showcase the issue Reviewed By: cortinico Differential Revision: D94508659 Pulled By: huntie fbshipit-source-id: a7576e86ad188c917dfc2d2371b609e5b6a02a28
This commit is contained in:
1 parent
34779df83a
commit
947f5cd5b4
1 file changed
+5
@@ -10,11 +10,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
haste: {
|
||||
defaultPlatform: 'ios',
|
||||
platforms: ['android', 'ios', 'native'],
|
||||
},
|
||||
moduleNameMapper: {
|
||||
'^react-native($|/.*)': `${path.dirname(require.resolve('react-native'))}/$1`,
|
||||
},
|
||||
resolver: require.resolve('./jest/resolver.js'),
|
||||
transform: {
|
||||
'^.+\\.(js|ts|tsx)$': 'babel-jest',
|
||||
|
||||
Reference in new issue
Block a user