简体   繁体   English

React更新为16.0失败的测试用例

[英]React Updated For 16.0 Failing Test Cases

I updated the react version with 16.0.0 and enzyme with 2.8.6 but still getting error can't find module react/lib/React . 我用16.0.0更新了react版本,并用2.8.6更新了酶,但是仍然出现错误,找不到模块react / lib / React。

How to fix these issues 如何解决这些问题

Configuring Mocha... Warning: ReactTestUtils has been moved to react-dom/test-utils. 正在配置Mocha ...警告:ReactTestUtils已移至react-dom / test-utils。 Update references to remove this warning. 更新引用以删除此警告。 module.js:471 throw err; module.js:471 throw err;

Error: Cannot find module 'react/lib/React'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

React 16 removed the ability to access React's internals through react/lib/.. . React 16删除了通过react/lib/..访问React内部的功能 Doing so has always been frowned upon, but it became a hard error in the latest version. 这样做一直不被接受,但是在最新版本中,这变成了一个硬错误。

If your code is relying on importing from that directory, you'll need to fix it. 如果您的代码依赖于从该目录导入,则需要对其进行修复。 If one of your dependencies is relying on it, then they'll need to fix it. 如果您的依赖项之一依赖于此,则他们需要对其进行修复。 Based on David Tryon's comment, it sounds like you need to update Enzyme to v3 in this case. 根据David Tryon的评论,在这种情况下,听起来您需要将Enzyme更新到v3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM