Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arnojong opened this issue May 13, 2019 · 9 comments
Closed

Comments

@arnojong
Copy link

arnojong commented May 13, 2019

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

@jennifer-shehane
Copy link
Member

Hey @arnojong, thanks for providing the test code to reproduce the issue. Unfortunately, when I run the code above, I get some different errors.

Screen Shot 2019-05-14 at 12 48 58 PM

Do you have anything in your cypress.json configuration file that I should also have set up?

Can you send a screenshot of the TypeError you are seeing in the Test Runner? I'd like to see where this is being thrown.

You should also be able to click the error in the Command Log with devtools open and see the stack trace of the error printed within the console - this may help you track down where the error is throwing.

Let me know!

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label May 14, 2019
@arnojong
Copy link
Author

Hey Jennifer,

There's nothing in my cypress.json file.
Below I attached a screenshot of the test runner.

image

I thought it may have something to do with clearing cookies, as it's a Magento based website, because of that I whitelisted all cookies, but the test still fails with the same error.

@jennifer-shehane
Copy link
Member

@arnojong Can you open the DevTools and click on the yellow error? This should print the stack trace in the console. Can you send a screenshot or what is printed there please? Thanks!

@arnojong
Copy link
Author

@jennifer-shehane Here you go!
image

@jennifer-shehane
Copy link
Member

@arnojong This error is coming from your application's code at https://geluk.com/static/frontend/Elephant/jumbo/nl_NL/jquery/jquery.storageapi.min.js:2:1921 as indicated in the stacktrace. Normally Cypress has a better error message - mentioning that the error is coming from your application.

I would suggest looking into why that is happening at that line of code.

I can't give much more insight since I haven't been able to run this locally and get the same error. We'd need a reproducible example.

@jennifer-shehane
Copy link
Member

Unfortunately we have to close this issue as there is not enough information to reproduce the problem.

Please comment in this issue with a reproducible example and we will reopen the issue. 🙏

@WinstonN
Copy link

WinstonN commented Nov 3, 2019

Hi @arnojong just dropping a comment here, to let you know that I saw the same error. I see you're also running a Magento site. This error happens sporadically and I am not able to accurately reproduce is - no action is needed here, I just thought I'd let you know that there is someone else in the world that saw this :)

@paulmaxwell
Copy link

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

@WinstonN
Copy link

WinstonN commented 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants