the-road-to-learn-react / react-testing-mocha-chai-enzyme

A solid test setup for React components with Mocha, Chai, Sinon, Enzyme in a Webpack/Babel application.
https://www.robinwieruch.de
49 stars 26 forks source link

Error: ShallowWrapper::state() can only be called on class components #23

Closed ganebabuk closed 2 years ago

ganebabuk commented 3 years ago

Hi,

I am getting following error when I tried to access the state from other component spec instead of App component spec, Could you please help for access the other component state variable in respective spec file?

_ Color Picker: Error: ShallowWrapper::state() can only be called on class components at ShallowWrapper.state (nodemodules/enzyme/src/ShallowWrapper.js:1192:13) at Context. (src/components/DeviceDetails/DeviceDetails.spec.js:61:49) at processImmediate (internal/timers.js:456:21)

Thnx

ganebabuk commented 2 years ago

No one replied