【问题标题】:React-Redux-Form nested component testingReact-Redux-Form 嵌套组件测试
【发布时间】:2017-07-01 10:42:40
【问题描述】:

我在应用程序的客户端使用 React-Redux-Form 和 React-Bootstrap。

我不知道如何测试我的组件。我在 github 上做了一个小项目,其中一个名为 LoginModal 的组件: https://github.com/DmitryIvanovIAMM/react-redux-form-login-test/blob/master/src/tests/Foo-test.js.

要开始测试,我正在关注本教程https://www.codementor.io/vijayst/unit-testing-react-components-jest-or-enzyme-du1087lh8。 但是当我尝试在我的渲染组件中使用 .find() 按钮时,结果是一个长度为零的数组。所以我无法模拟它的行为。我尝试以几种不同的方式找到它(按钮)但不成功。请您的建议。

【问题讨论】:

    标签: reactjs jestjs react-redux-form


    【解决方案1】:

    此问题与作为 #react-bootstrap 一部分的 Modal 组件的呈现有关。在https://github.com/react-bootstrap/react-bootstrap/issues/876 上有关于它的讨论。 另一种方法是使用 react-modal 中的 ReactModal。测试它在http://remarkablemark.org/blog/2017/05/17/testing-react-modal/ 上描述

    【讨论】:

    • 谢谢!这真的很有帮助
    猜你喜欢
    • 2019-05-26
    • 2015-07-19
    • 2016-10-14
    • 2019-06-10
    • 1970-01-01
    • 1970-01-01
    • 2018-01-19
    • 2020-06-21
    • 1970-01-01
    相关资源
    最近更新 更多