- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们最近将一个应用程序从 ReactNative 0.42 更新到了 0.48。在那次更新中,我们迁移到 Jest 进行测试(来自 mocha/chai/enzyme)。我们目前正在使用 Jest v21.1.0。当我手动运行每个测试时,它们都无误地通过了。当我只运行 yarn jest
时,我得到这个错误:
/scratch/react_native_app/client/node_modules/react-native/Libraries/Renderer/ReactNativeStack-dev.js:2582
warnForStyleProps$1(nativeProps,viewConfig.validAttributes);
^
TypeError: Cannot read property 'validAttributes' of undefined
at setNativePropsStack$1 (/scratch/react_native_app/client/node_modules/react-native/Libraries/Renderer/ReactNativeStack-dev.js:2582:43)
at Component.setNativeProps (/scratch/react_native_app/client/node_modules/react-native/Libraries/Renderer/ReactNativeStack-dev.js:2550:1)
at AnimatedProps.callback [as _callback] (/scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:1819:20)
at AnimatedProps.update (/scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:1698:6)
at /scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:230:69
at Set.forEach (native)
at _flush (/scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:230:16)
at AnimatedValue._updateValue (/scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:939:1)
at TimingAnimation.animation.start._this9._animation [as _onUpdate] (/scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:906:8)
at TimingAnimation.onUpdate (/scratch/react_native_app/client/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:345:6)
我不能确定,但我们只有两个处理动画和计时的组件。我们正在使用 jest.useFakeTimers();
如果我添加一个 jest.runAllTimers();
我可以在单个组件上得到错误。组件的计时部分如下所示:
componentDidMount() {
Animated.timing(
this.state.fadeAnim, {
toValue: 1,
delay: 2000
}
).start();
}
和
<Animated.View style={{ opacity: this.state.fadeAnim }}>
...
</Animated.View>
最佳答案
我花了很长时间,但我终于弄明白是怎么回事了。基本上,我想的更多的测试是渲染动画 View 。我最初将 jest.useFakeTimers();
包含在我对该组件的特定测试中,但后来我将其移至名为 test/jest_setup.js
的设置文件中,然后添加这是我的 package.json
文件:
"jest": {
"setupFiles": [
"./node_modules/react-native/jest/setup.js",
"./test/jest_setup.js"
],
// rest of jest config
}
现在我的错误消失了!
关于react-native - ReactNative 0.48 上的开 Jest 错误 "Cannot read property ' validAttributes' of undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46432694/
Reactnative可以调用原生模块,原生模块也可以给JavaScript发送事件通知.最好的方法是继承RCTEventEmitter.自定义继承自PushEventEmitter的子类RCTEv
我对 React-Native 和 JavaScript 很陌生。我真的不知道如何开始这个小项目 用户可以为每个问题选择 1 个选项 你最喜欢什么宠物? 一只狗 一只猫 您希望您的宠物是什么颜色 红色
我正在使用List从 NativeBase 渲染数据。我尝试过这样设置: body = }
我是 React Native 的新手,一直在尝试一两个示例。当我尝试在我的 Mac 上构建 Android“电影”示例时,出现以下错误: ./gradlew :Examples:Movies:and
已编辑 我是 ReactNative 的新手,我正在尝试在我的文本框上书写。但是,我无法输入任何内容。我尝试将 redux 表单添加到注册屏幕。这是我的 Signup.js : import Reac
单击文本时,我收到一条错误消息“undefined is not an object (evaluating '_this2.categoryClicked.bind')” 我认为错误是“onPres
zzz@zzz-PC ~/AndroidStudioProjects/Example $ react-native run-android Scanning 555 folders for symli
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我们正在尝试构建使用静态库和 cocoapods 依赖项的 ios React native 应用程序。所有依赖项都需要 React。我们面临的问题是,当我们包含静态库时,我们也需要将 React 包
您对如何做到这一点有什么想法吗? 通过单击按钮打开的下拉列表,此下拉列表包含其他项目列表。如果可能的话,动态地! 例如:类别:水果,食品(第一个下拉列表)在这个类别中,每个类别都有一个列表: 水果:[
我已经开始开发一个 react native 应用程序,但我的 ListView 的初始化出现问题。 我正在使用react-native-db-models插件来存储和检索我的数据 问题是我想在rea
尝试在 Android 模拟器上运行我的项目时,设备抛出此错误 emulator screenshot .我似乎无法弄清楚我做错了什么。我还是很新的 react 最佳答案 首先安装babel poly
我有一个事件部分,其中的部分标题包含日期。我需要能够跳转到特定日期,并将初始滚动位置设置为 future 的第一个日期。 为了跳转到特定日期,我尝试将它们的 y 位置存储在状态中。 renderSec
是否可以挂接到 React-Native 的平台特定扩展以使用自定义扩展? 以同样的方式你可以区分 .ios.js 和 .android.js,有没有办法定义自定义扩展 .xyz.js。 (相当于 w
我致力于 React Native(React 16.2.0,React Native 0.54) 我使用 flatlist 显示大量项目。我们可以以拥有 1000 名员工的联系人列表为例。 平面列表
我正在尝试使用我的上下文中的值/函数,但每次我 console.log 一个从上下文中 Coes 的值时,该值是未定义的。 这是我的上下文: import { NativeStackNavigatio
如果我尝试滚动到 ScrollView 的底部,它会弹回其默认位置,并且不会让我查看其全部内容。 我的(截断的)设置相当简单:
我的应用程序中有一个表单,我希望用户能够通过单击“下一步”返回按钮转到下一个 TextInput。我的输入组件: export default class Input extends Comp
这个问题在这里已经有了答案: Basic FlatList code throws Warning - React Native (13 个回答) 4年前关闭。 我正在关注 SectionLists
我希望在 React Native 中使用这个包,这是一个用 Flatlist 实现的轮播,并允许水平滑动来滑动图像。 https://github.com/gusgard/react-native-
我是一名优秀的程序员,十分优秀!