小编Gra*_*ane的帖子

由于反应导航生成的密钥,Jest 快照测试失败

我的 Jest 测试失败,因为每次运行测试时密钥中的时间戳都不同:

\n\n
 FAIL  ./App.test.js\n  \xe2\x9c\x95 renders without crashing (72ms)\n\n  \xe2\x97\x8f renders without crashing\n\nexpect(value).toMatchSnapshot()\n\nReceived value does not match stored snapshot 1.\n\n- Snapshot\n+ Received\n\n@@ -347,11 +347,11 @@\n              "index": 0,\n              "isTransitioning": false,\n              "key": "StackRouterRoot",\n              "routes": Array [\n                Object {\n-                 "key": "id-1519567169760-0",\n+                 "key": "id-1519567814666-0",\n                  "routeName": "Menu",\n                },\n              ],\n            },\n          }\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的 App.js 文件:

\n\n
import React from \'react\';\nimport { StackNavigator } from \'react-navigation\';\nimport Menu from \'./components/Menu\';\nimport List from \'./components/List\';\n\nconst RootStack = StackNavigator(\n  {\n    Menu: {\n      screen: Menu,\n    },\n    List: {\n      screen: …
Run Code Online (Sandbox Code Playgroud)

jestjs react-native react-navigation

5
推荐指数
1
解决办法
9187
查看次数

如何检测ReactJS何时完成页面操作?

我们的客户将我们的JS标签添加到页面的顶部。我们的标签需要在修改页面之前知道reactJS何时完成。

我已经尝试使用jQuery,$(document).ready()但是在reactJS完成之前会触发。我可以使用,$(window).load()但是如果页面上有很多图像,这将太慢。

有哪些绑定完成的选项React.renderComponent

reactjs

4
推荐指数
2
解决办法
1706
查看次数

标签 统计

jestjs ×1

react-native ×1

react-navigation ×1

reactjs ×1