我目前面临的一个问题是样式表.create的每个页面都是失败的原因,并且不确定是为什么。.但是有人可以给我一个解释或解决方案吗?
还有一件事,没有酶(我使用的是本机0.56,我还没有找到酶的安装文件。)我可以基于一个类(例如带有两个按钮作为测试用例的主页)来模拟一个按钮都在印刷吗?
●测试套件无法运行
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)
您需要模拟它。
jest.mock('react-native', () => {
let items = {};
StyleSheet: {
create: () => ({})
},
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句