gpt4 book ai didi

jestjs - 类型错误 : Cannot read property 'LENGTH_LONG' of undefined

转载 作者:行者123 更新时间:2023-12-02 20:21:57 31 4
gpt4 key购买 nike

我正在用 React Native 进行开 Jest 测试,并且在我的项目中使用了 snackbar。执行 Jest 时出现此错误。'LENGTH_LONG' 是 snackbar 中的内置变量。我在使用“LENGTH_LONG”变量和错误消息的地方发布。任何人都请帮助我

 jest "login"

FAIL __tests__\jest\LoginScreen.test.js
● Test suite failed to run

TypeError: Cannot read property 'LENGTH_LONG' of undefined

10 | ScrollView
11 | } from "react-native";
> 12 | import Snackbar from 'react-native-snackbar';
13 |
14 | import { connect } from "react-redux";
15 | import { Button, Text, Divider } from "react-native-elements";

at Object.<anonymous> (node_modules/react-native-snackbar/lib/index.js:1:252)
at Object.<anonymous> (src/screens/login/loginScreen.js:12:26)
at Object.<anonymous> (__tests__/jest/LoginScreen.test.js:3:18)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.689s, estimated 4s
Ran all test suites matching /login/i.

代码是

render() {
return (
<View style={styles.mainContainer}>
{this.renderTopLogoContainer()}
{this.renderBottomContainer()}

{this.props.hasError ? Snackbar.show({
title: this.props.error.display_message,
duration: Snackbar.LENGTH_LONG
}) : null}
</View>
);
}

最佳答案

https://github.com/cooperka/react-native-snackbar/tree/master/examplemocks 文件夹中添加 react-native-snackbar.js 文件

关于jestjs - 类型错误 : Cannot read property 'LENGTH_LONG' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51174042/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com