升级反应后酶座破裂

时间:2019-02-15 16:45:22

标签: reactjs testing enzyme

我不确定如何确切地解释问题,因为我自己不太了解。 我将我的反应/种族dom升级到16.6.3 之后,我项目中的所有测试均失败了,首先,它显示了有关旧浏览器的polyfill的警告,经过数小时的互联网挖掘,我终于摆脱了这一警告。但是,我所有的测试仍然失败。 我做了一些进一步的挖掘,大多数人都建议同时升级酶反应适配器和酶。所以现在我也有 酶3.8.0 enzyme-adapter-react-16.3 1.6.1 ..但测试仍然失败。

这是我要进行其中一项测试的错误消息

Error: Enzyme Internal Error: unknown node with tag 7
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:225:13)
    at Array.map (<anonymous>)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:189:70)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at Array.map (<anonymous>)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:189:70)
    at Array.map (<anonymous>)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:189:70)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at Array.map (<anonymous>)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:189:70)
    at Array.map (<anonymous>)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:189:70)
    at Array.map (<anonymous>)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:189:70)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:162:21)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at childrenToTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:238:12)
    at toTree (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:184:19)
    at Object.getNode (node_modules\enzyme-adapter-react-16.3\build\ReactSixteenThreeAdapter.js:350:33)
    at new ReactWrapper (node_modules\enzyme\build\ReactWrapper.js:136:44)
    at Object.mount (node_modules\enzyme\build\mount.js:21:10)
    at Context.<anonymous> (C:/Users/EHU/sModal.test.jsx:119:36)

这是测试本身

it("should be shown with default values", () => {
        // Init

        // Action
        const wrapper = mount(<sModal.wrappedComponent {...provided}/>);

        // Test
        expect(wrapper.find("h2").text()).to.be.equal("TestHeader");
    });

过去六个小时来,我一直在寻找解决方案,但没有明确的答案。有人建议我导入 core-js / es6 / map core-js / es6 / set 。但这也不起作用,我什至根本不知道这与问题有什么关系。我认为包装程序没有采用子节点,这就是问题所在,但我不确定。 任何帮助都很棒

在升级到反应16 之前,我的代码和所有测试都运行良好。升级之前,我正在运行酶3.3.0 enzyme-adapter-react-16 1.1.1

1 个答案:

答案 0 :(得分:0)

安装最新版本的enzyme-adapter-react-16

yarn add -D enzyme-adapter-react-16@last