ReactTestUtils has been moved

前端 未结 4 1275
南笙
南笙 2020-12-28 17:20

I\'m starting learning React and while I was doing some tests i noticed two warning messages:

Warning: ReactTestUtils has been moved to react-dom/test-ut

4条回答
  •  醉梦人生
    2020-12-28 17:33

    I think it's coming from using the shallow render function from enzyme, which has not been updated for v15.5 yet (there is a pull request for it though).

    You can try to use one of the other render function (render or mount), but this will change the semantics of your test (and may or may not still produce the warning).

    Your other option is to not use enzyme and use react-test-renderer/shallow yourself, but the enzyme API is quite nice for testing components.

    My advice is to wait for the version of enzyme and just live with the warning for now.

提交回复
热议问题