Open toninlopes opened 4 weeks ago
The jest.config.js
file has the property setupFiles
. So, for my surprise, when I remove that property, the test passed. And that made me think that the issue would be missing mock piece of code. So, I started to review the mocks and I found out the one was causing the issue.
Before
jest.mock('react-native/Libraries/Utilities/Dimensions', () => ({
get: jest.fn(),
set: jest.fn(),
addEventListener: jest.fn(),
}));
After
jest.mock('react-native/Libraries/Utilities/Dimensions', () => ({
get: jest.fn().mockImplementation(() => {
return { width: 375, height: 812, scale: 0, fontScale: 0 };
}),
set: jest.fn(),
addEventListener: jest.fn().mockImplementation(() => {
return { remove: jest.fn() };
}),
}));
Description
Testing Snapshot NativeBase components failed
CodeSandbox/Snack link
https://github.com/toninlopes/NativeBaseSample
Steps to reproduce
yarn test
NativeBase Version
3.4.28
Platform
Other Platform
No response
Additional Information
I have set up a standard React Native + Native Base project. See the package.json.
Here is a simple snapshot test with @testing-library/react-native and react-test-renderer.
Tests 1 and 2 use the
<NativeBaseProvider />
as wrapper and both libraries gets the same error.