Closed idrissakhi closed 9 months ago
You'll likely need to mock Image.resolveAssetSource
method to return something
@thymikee but it was working fine on previous versions, also i saw the new react native changelog and no breaking change is introduced in this part
It's possible it was unintended breaking change. To unblock yourself you could do something like:
Image.resolveAssetSource = jest.fn(() => ({width: 128, height: 128}));
or use jest.mock
/jest.spyOn
if jest.fn
won't work here
Closing as it appears to be RN issue, not a RNTL one.
Future googlers, @thymikee's solution worked in 2024 for react-native 0.73.0 and @testing-library/react-native@12.5.2
Describe the bug
const emailMailImage = require('assets/images/email-mail/mail.png');
const emailMailImageDimensions = Image.resolveAssetSource(emailMailImage);
TypeError: Cannot read properties of undefined (reading 'width')Jest
Expected behavior
Tests passe on 0.72.X
Steps to Reproduce
install react native 0.73.0 and run a test having
Screenshots
Versions
npmPackages: @testing-library/react-native: 12.4.1 => 12.4.1 react: 18.2.0 => 18.2.0 react-native: 0.73.0 => 0.73.0 react-test-renderer: 18.2.0 => 18.2.0