enzyme: 16.8 (react-test-renderer) causing build failures

So react-test-renderer (Dependency of enzyme-adapter-react-16@1.7.1) had a minor release 6 hours ago. Causing our builds to fail all over. We have explicitly added react-test-renderer@16.7.0 in our devDependencies to circumvent that.

Running "test:jest" task
[D] Task source: tasks/test_jest.js
 FAIL  ui_framework/components/form/check_box/check_box_label.test.js
  ● KuiCheckBoxLabel › Props › onChange › is called when checkbox is changed

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.test (ui_framework/components/form/check_box/check_box_label.test.js:86:45)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  ui_framework/components/form/check_box/check_box.test.js
  ● KuiCheckBox › Props › onChange › is called when checkbox is changed

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.test (ui_framework/components/form/check_box/check_box.test.js:75:45)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  ui_framework/components/button/button.test.js
  ● KuiButton › Props › onClick › isn't called upon instantiation

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.test (ui_framework/components/button/button.test.js:104:29)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● KuiButton › Props › onClick › is called when the button is clicked

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.test (ui_framework/components/button/button.test.js:114:45)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  ui_framework/components/button/submit_button.test.js
  ● KuiSubmitButton › Props › onClick › isn't called upon instantiation

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.test (ui_framework/components/button/submit_button.test.js:65:29)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● KuiSubmitButton › Props › onClick › is called when the button is clicked

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.test (ui_framework/components/button/submit_button.test.js:75:45)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  src/core_plugins/metrics/public/components/vis_types/gauge/vis.test.js
  ● renders

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/components/vis_types/gauge/vis.test.js:97:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  src/core_plugins/metrics/public/components/icon_select.test.js
  ● renders

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/components/icon_select.test.js:6:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  src/core_plugins/metrics/public/visualizations/components/vertical_legend.test.js
  ● legend renders: right

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/vertical_legend.test.js:8:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● legend renders: left

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/vertical_legend.test.js:16:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● Click works.

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/vertical_legend.test.js:25:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● onToggle works.

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/vertical_legend.test.js:35:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  src/core_plugins/metrics/public/visualizations/components/legend.test.js
  ● legend vertical

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/legend.test.js:8:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● legend horizontal

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/legend.test.js:16:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

 FAIL  src/core_plugins/metrics/public/visualizations/components/horizontal_legend.test.js
  ● horizontal legend renders

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/horizontal_legend.test.js:8:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  ● Click works.

    TypeError: Cannot read property 'current' of undefined
      
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:703:53)
      at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:460:37
      at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:143:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:459:70)
      at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:206:22)
      at shallow (node_modules/enzyme/build/shallow.js:21:10)
      at Object.<anonymous>.test (src/core_plugins/metrics/public/visualizations/components/horizontal_legend.test.js:17:41)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:68:7)


About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 13
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Hey We found a solution, which was:

  1. update "enzyme-adapter-react-16": "1.1.0" to "enzyme-adapter-react-16.3": "1.6.1",
  2. within your enzymeSetup change import Adapter from 'enzyme-adapter-react-16 to Adapter from enzyme-adapter-react-16.3

I was experiencing this same exact issue in only a couple of my tests. I am on the latest 16.8.6 version of react (all the things), and latest enzyme(3.9.0) and adapter(1.11.2). I found that what fixed it was changing the import order.

Importing my React components BEFORE my import of import Adapter from 'enzyme-adapter-react-16'; would result in it breaking. Importing my React components AFTER importing the adapter worked.

Breaking:

import React from 'react';
import Enzyme, { shallow, mount } from 'enzyme';
import { TestComponent } from './test.component';
import Adapter from 'enzyme-adapter-react-16';

Working:

import React from 'react';
import Enzyme, { shallow, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { TestComponent } from './test.component';

Also, this issue only seemed to occur when using mount, shallow was not affected by this.

Yes, that’s exactly what we did to circumvent this issue. And reported it to help others out.

@ljharb will do, thank you! Just submitted a new issue: https://github.com/airbnb/enzyme/issues/2110

Have same issue when running tests with react 16.8 and enzyme 1.9.1, works fine in 16.7 with enzyme 1.9.0

@varunsharma27 first, you’re not using the latest version of your react adapter. Please update to the latest.

Can you confirm - if you have the latest enzyme, enzyme-adapter-react-16, react, and react-dom (and if you have a lockfile, that react-test-renderer is also updated to 16.8), do you still see issues?