TypeError: Cannot read property 'length' of null (7.26.4)
See original GitHub issue@testing-library/dom
version: 7.26.4- Testing Framework and version: jest: 26.6.2
- DOM Environment: jsdom: 8.5.0
Relevant code or config:
test(`should select rule type from selector`, async () => {
renderCampaignShowRoot({
store: rootStore,
activeRoute,
})
const createRuleButton = await screen.findByTestId(
'ac-cr-loyalty-create-new-rule',
)
userEvent.click(createRuleButton)
expect(
await screen.findByTestId('ac-cr-loyalty-create-rule-modal'),
).toBeInTheDocument()
const select = screen.getByLabelText('Action type')
await selectEvent.select(select, 'Purchase points')
expect(await screen.findByText('Purchase points')).toBeInTheDocument()
})
What happened:
TypeError: Cannot read property 'length' of null
314 | ).toBeInTheDocument()
315 |
> 316 | const select = screen.getByLabelText('Action type')
| ^
317 |
318 | await selectEvent.select(select, 'Purchase points')
319 |
at node_modules/@testing-library/dom/dist/queries/label-text.js:63:53
at Array.filter (<anonymous>)
at queryAllByLabelText (node_modules/@testing-library/dom/dist/queries/label-text.js:62:80)
at getAllByLabelText (node_modules/@testing-library/dom/dist/queries/label-text.js:101:15)
at node_modules/@testing-library/dom/dist/query-helpers.js:62:17
at getByLabelText (node_modules/@testing-library/dom/dist/query-helpers.js:106:19)
Problem description:
After update @testing-library/dom: 7.26.3 -> 7.26.4 (https://github.com/testing-library/dom-testing-library/pull/790), tests started to fall
These changes affected specs which use these helpers:
findByLabelText
getByLabelText
other specs works fine
Suggested solution:
Add to docs what users should do to fix this or fix this behavior
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'length' of Null in JS
The "Cannot read property 'length' of null" error occurs when accessing the length property on a null value. To solve the error, make...
Read more >Cannot read property 'length' of null, javascript. Check if given ...
The error means that you're trying to access the .length property of something without first determining that the something is not null ....
Read more >[Solved] TypeError: Cannot read property 'length' of null
This error indicates that the code is trying to compute the length property on a null variable. A null variable holds no or...
Read more >Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >Cannot read property 'length' of null · Issue #43476 - GitHub
The root cause is in the preferencesRenderer.ts file, where we pass in null as an argument to deltaDecorations .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
New versions are released automatically. Unfortunately TravisCI recently made changes to their OSS plan which severely limits how frequently those runs happen. I’m investigating moving to GitHub actions for this. But you’ll get a new version soon (most likely in the next few hours). Thanks for your patience.
@marcosvega91 can you publish a new version?