react-native - 如何模拟反应原生 3rd 方模块“rn-sliding-up-panel”
问题描述
我正在尝试在我的新react native init项目中运行纱线测试,并在我的项目中添加了第 3 方模块,例如 rn-sliding-up-panel
在我的 App.js 中看起来像这样:
import React from 'react';
import {View, Button, Text} from 'react-native';
import SlidingUpPanel from 'rn-sliding-up-panel';
const styles = {
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center'
}
}
class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Button title='Show panel' onPress={() => this._panel.show()} />
<SlidingUpPanel ref={c => this._panel = c}>
<View style={styles.container}>
<Text>Here is the content inside panel</Text>
<Button title='Hide' onPress={() => this._panel.hide()} />
</View>
</SlidingUpPanel>
</View>
)
}
}
不知何故,在我运行纱线测试后,它失败了:
● Test suite failed to run
/The Codes/ssa-mobile/node_modules/rn-sliding-up-panel/SlidingUpPanel.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React from 'react'
^^^^^
SyntaxError: Unexpected identifier
有没有办法通过添加这个第 3 方模块来通过纱线测试笑话?
注意:在我使用这个“rn-sliding-up-panel”模块之前,测试工作完美
解决方案
推荐阅读
- postgresql - PostgreSQL:如何更改 log_min_duration_statement 以使更改生效?
- java - 只有阿拉伯语文本改变大小,而不是字符串上的其他文本
- mysql - 我是否应该使用另一列来显示 LONGTEXT 是否包含数据?
- python - sqlalchemy.exc.InvalidRequestError:需要 SQL 表达式、列或映射实体 - 得到 '
' - lotus-notes - LotusScript - 按主题查找文档
- html - 样式表未正确使用 html 文件,但它适用于其他 html 文件
- azure - Azure 服务总线主题重复检测
- c# - C#:如果我只有它的名称,如何使用按钮(fe,甚至其他对象)?
- azure-active-directory - Webview2 SPA SSO
- corda - Corda 节点连接到 Oracle 数据库时无法启动