kentcdodds / jest-cypress-react-babel-webpack

Configure Jest for Testing JavaScript Applications and Install, Configure, and Script Cypress for JavaScript Web Applications on TestingJavaScript.com
https://testingjavascript.com
Other
512 stars 329 forks source link

"Cannot read properties of undefined (reading 'theme')" Error after setting up optional theme parameter in calculator-test-utils.js #47

Closed mturich closed 1 year ago

mturich commented 2 years ago

Hey Kent,

I notices that I get an error when I change my calculator-test-utils.js file to handle an optional theme parameter. If I specify the theme, everything works fine but it I omit it, I get this "Cannot read properties of undefined (reading 'theme')" error, which I also saw on your screen.

Screen Shot 2022-08-02 at 8 52 20 AM

link to the lesson (10 min, 4 sec): https://testingjavascript.com/lessons/jest-support-a-test-utilities-file-with-jest-moduledirectories

I tried a few things and finally found this solution but I am not sure if it breaks the options object in general if only the theme parameter is left undefined. Screen Shot 2022-08-02 at 8 58 55 AM

detailed view Screen Shot 2022-08-02 at 9 01 06 AM

mturich commented 2 years ago

I saw the code base is already changed although the video still shows the error.