hashguard
hashguard

Reputation: 463

enzyme mount is breaking after upgrading react

i'm not sure how to explain the problem exactly because I myself don't understand it much. I upgraded my react/raect-dom to 16.6.3 and after that all the tests in my project failed, first it was showing a warning about a polyfill for old browsers and after hours of internet digging I managed to get rid of that warning. However, all my tests are still failing. I did some more digging and the majority recommended to upgrade enzyme-react-adapter and enzyme as well. so now I have also, enzyme 3.8.0 and enzyme-adapter-react-16.3 1.6.1 .. but the tests are still failing.

This is the error msg i'm getting for one of the tests

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)

and this the test itself

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");
    });

I've been searching for a solution for the past six hours with no solid answer. someone suggested I import core-js/es6/map and core-js/es6/set. But that didn't work either, I don't even know how that relates to the problem in the first place. I think that the wrapper is not taking in the children nodes and that's the problem, but i'm not sure really. Any help would be awesome

My code and all tests were running just fine before upgrading to react 16. I was running enzyme 3.3.0 and enzyme-adapter-react-16 1.1.1 before upgrading

Upvotes: 2

Views: 2329

Answers (1)

nrm97
nrm97

Reputation: 87

install the lastest version of enzyme-adapter-react-16

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

Upvotes: 0

Related Questions