question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot convert undefined or null to object failing the test

See original GitHub issue

Current 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:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
WinstonNcommented, Nov 15, 2019

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

Cypress.LocalStorage.clear = function(keys, ls, rs) {};

That has prevented the error from firing, and my tests, now function as they should

Hope it helps!

0reactions
paulmaxwellcommented, Nov 6, 2019

Also seeing this error with Magento, but only in the graphic test runner. Tests work fine in the CLI.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found