I have trying to test the basic example provided in react-testing-library documentation. I exactly copied and pasted this code here
It's failing no matter what.
Here the failing test result:
shows the children when the checkbox is checked
TypeError: Cannot read property 'current' of undefined
34 | test('shows the children when the checkbox is checked', () => {
35 | const testMessage = 'Test Message'
> 36 | const {queryByText, getByLabelText, getByText} = render(
| ^
37 | <HiddenMessage>{testMessage}</HiddenMessage>,
38 | )
39 |
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:983:55)
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1418:12)
at render (node_modules/@testing-library/react/dist/pure.js:82:26)
at Object.<anonymous> (src/components/Authentication/SignUp/index.test.js:36:52)
● shows the children when the checkbox is checked
TypeError: Cannot read property 'current' of undefined
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:983:55)
at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1418:12)
at node_modules/@testing-library/react/dist/act-compat.js:57:20
at asyncAct (node_modules/@testing-library/react/dist/act-compat.js:38:14)
at Object.<anonymous> (node_modules/@testing-library/react/dist/index.js:28:35)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.318s, estimated 3s
Ran all test suites related to changed files.
Any ideas?
HiddenMessagecomponent.