TypeError: Cannot convert undefined or null to object failing the test
See original GitHub issueCurrent behavior:
My tests are failing because of the TypeError: Cannot convert undefined or null to object
failing the test
Steps to reproduce
I wrote the following test, yet it fails, I followed the documentation but don’t see what I did wrong.
context('Checkout', () => {
before(() => {
cy.visit('https://www.geluk.com/feest-en-themadagen')
})
it('clicks the first product', () => {
cy.get('.product-item__title').contains('Amerigo').click()
})
it('clicks the custom product options', () => {
cy.get('select.product-custom-option').eq(0).select('Geen')
cy.get('select.product-custom-option').eq(3).select('Geen')
})
it('clicks the checkout button', () => {
cy.contains('Direct bestellen').click()
})
it('checks if we are on the right location', () => {
cy.url().should('include', '/onestepcheckout')
})
})
Versions
Cypress version 3.2.0, using npx cypress open
to show the runner, no changes made to that.
Mac OSX Mojave 10.14
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Cannot convert undefined or null to object - Stack Overflow
Generic answer. This error is caused when you call a function that expects an Object as its argument, but pass undefined or null...
Read more >Cannot convert undefined or null to Object in JavaScript
The "Cannot convert undefined or null to Object" error occurs when we pass a null or an undefined value to a function that...
Read more >typeerror: cannot convert undefined or null to object - You.com
Solve The Error “TypeError: Cannot convert undefined or null to object” Solution 1: Check if the value is null or undefined before operating...
Read more >Cannot convert undefined or null to object at Function.keys ...
It looks like the fv object is null or undefined , and this why it says it can't get the keys. Could you...
Read more >webdriverio/webdriverio - Gitter
ERROR @wdio/local-runner: Failed launching test session: TypeError: Cannot convert undefined or null to object at execHook (/.
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 FreeTop 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
Top GitHub Comments
Hi,
I have had some time to look into this error
It appears for me when selecting product options, address autocomplete drop down options, and it prevented my checkout from completing
I first started by going over the versions of https://github.com/julien-maurel/jQuery-Storage-API, to see if I can upgrade, but that did not solve my issue
Early on in my tests, I saw that my local storage (which Magento 2 depends on) are being cleared. This is a philosophy of Cypress and I agree with it, but Magento depends on that storage data being set - I found the same for cookies btw
What I ended up doing was to set the below at the top of my test
That has prevented the error from firing, and my tests, now function as they should
Hope it helps!
Also seeing this error with Magento, but only in the graphic test runner. Tests work fine in the CLI.