小编Loï*_*c M的帖子

Jest 和 React Native 图标导入问题

我是原生反应新手,遇到了测试问题。\n首先,我的应用程序运行正常。\n只有当我想用玩笑测试我的应用程序并且我的应用程序中有图标时,才会出现该问题。

\n

以下消息告诉我,可能存在延迟导入加载,在某些方面与笑话冲突,但我不知道如何解决或修复此问题:\nReferenceError: You are trying to 'import' a file after the Jest environment has been torn down.

\n

我已经测试了我的应用程序,icon="camera"并且测试运行良好,因此它与图标非常相关。

\n

该应用程序还使用react-native-paper。

\n

即使应用程序中有图标,我如何测试它?

\n

这是重现该错误的最小 App.js:

\n
import { StatusBar } from 'expo-status-bar';\nimport React from 'react';\nimport { StyleSheet, Text, View } from 'react-native';\nimport { Provider as PaperProvider } from 'react-native-paper';\nimport { Button } from 'react-native-paper';\n\nexport default function App() {\n  return (\n    <PaperProvider>\n      <View style={styles.container}>\n        <Text>Thi is a test</Text>\n        <Button icon="camera" mode="contained" onPress={() => console.log('Pressed')}>\n          Press me\n …
Run Code Online (Sandbox Code Playgroud)

icons jestjs react-native react-native-paper

2
推荐指数
1
解决办法
4045
查看次数

标签 统计

icons ×1

jestjs ×1

react-native ×1

react-native-paper ×1