I am currently facing an issue where the every pages Stylesheet .create is the cause of the failure and not sure entirely why it is.. but can someone give me an explanation or a solution?
And one more thing, without enzyme (I am using react-native 0.56, I haven't found an enzyme installation file just yet.) can I simulate a press button based on a class such as a homepage with two buttons as a test case with both on Press?
● Test suite failed to run
TypeError: Cannot read property 'create' of undefined
162 | }
163 |
> 164 | const styles = StyleSheet.create({
| ^
165 | container: {
166 | flex: 1,
167 | justifyContent: 'center',
at Object.<anonymous> (components/landingpage.js:164:27)
at Object.<anonymous> (__tests__/landingpage.spec.js:3:1)
Correct syntax for Amin's answer:
jest.mock('react-native', () => {
return {
StyleSheet: {
create: () => ({}),
},
};
});
You need to mock it.
jest.mock('react-native', () => {
let items = {};
StyleSheet: {
create: () => ({})
},
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With