Cypress: Uncaught TypeError: Cannot read property 'id' of undefined

Created on 12 Jun 2018  路  5Comments  路  Source: cypress-io/cypress

Current behavior:

screen shot 2018-06-12 at 16 07 34

Desired behavior:

Gives me a confirmation prompt on click button.

Steps to reproduce:

screen shot 2018-06-12 at 17 23 34

Versions

Cypress: 3.0.1
OS: macOS High Sierra
Chrome: v66

Most helpful comment

If your application is using a window.confirm(), you'll want to handle that event programmatically in your tests. See the docs for listening to this.

As for the Uncaught error, we will need a reproducible example - with tests to run in order to track down why that is happening.

All 5 comments

If your application is using a window.confirm(), you'll want to handle that event programmatically in your tests. See the docs for listening to this.

As for the Uncaught error, we will need a reproducible example - with tests to run in order to track down why that is happening.

@jennifer-shehane Thanks, it's working now.

Got exact same "Cypress logging" error on a project using Quasar framework (which uses VueJS) ; happens only when using $this.router.push(...route...) in a mounted() method of a component.

Seems like the fix is pretty simple & already done for future version Cypress 4. (file log.coffee line 150)

鉃★笍 Dirty workaround for Cypress 3.x:

  • For a Windows installation, open file C:\Users\\AppDataLocal\Cypress\Cache\\Cypressresources\app\packages\runner\dist\cypress_runner.js (warning, heavy file 6MB, an editor like Sublime Text 3 can handle it)
  • Find the line containing exactly: testId: state("runnable").id and change it to testId: state("runnable") ? state("runnable").id : null
  • Save & close the file

Any chance that this could be addressed in future 3.x versions too?
Is there any info about release date of 4.x?

@mpacary Interestingly enough, I just recently fixed this error while running across it while working in Cypress in develop. The code was updated to check that state("runnable") is defined before getting it's id prop here: https://github.com/cypress-io/cypress/pull/3927

This PR is pending release in version 3.3.0

Yeah, I wish this had been pulled in from Version 4, but it likely wasn't because there were no existing issues open for this error that we found.

I'm not sure exactly why you're getting the error in this situation, it should easily happen. Do you not see any subsequent errors after fixing this line of code in your example?

@jennifer-shehane Thanks for replying & adding the fix to upcoming version 3.3.0 馃憤

Do you not see any subsequent errors after fixing this line of code in your example?

I've used Cypress quite intensively after fixing the issue ; no subsequent errors appeared.

Was this page helpful?
0 / 5 - 0 ratings