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

event is undefined in XHR onload handlers using cypress open #2859

meastes opened this issue Nov 29, 2018 · 5 comments

event is undefined in XHR onload handlers using cypress open #2859

meastes opened this issue Nov 29, 2018 · 5 comments


Copy link

@meastes meastes commented Nov 29, 2018

Current behavior:

Currently, Cypress will fail if the page uses an onload event handler and relies on data from the event. It appears that the event is undefined when the onload handler is executed. This issue only appears in Cypress 3.1.1 and 3.1.2; it is not present in Cypress 3.1.0 and earlier. Here is the code that fails for me:

var request = new XMLHttpRequest();'GET', '', true);
request.onload = function (evt) {
  if ( >= 200 && < 400) { // This will fail since evt will be undefined

It also appears that the test will execute fine with cypress run. Only cypress open has the issue.

Desired behavior:

Cypress should execute onload event handlers with the correct onload event.

Steps to reproduce:

An example of the issue is available at

  1. Clone
  2. Run npm install
  3. Run npm start to start the web server
  4. Run npm run cypress:open
  5. Execute the spec.js test
  6. Notice that it will fail because the event in the XHR request is undefined


Cypress 3.1.2, MacOS 10.13.6, Chrome 70

Copy link

@jennifer-shehane jennifer-shehane commented Nov 30, 2018

Thanks so much for providing a repo to reproduce the issue. I can indeed reproduce this running the code provided.

Test code:

it('works', () => {

Command Log on very 1st run:

screen shot 2018-11-30 at 11 02 04 am

Command Log on every run after 1st:

screen shot 2018-11-30 at 10 57 29 am

Copy link

@lilaconlee lilaconlee commented Dec 13, 2018

This was fixed with #2924 and will be part of the next release.

Copy link

@jennifer-shehane jennifer-shehane commented Mar 13, 2019

This was released in 3.1.5.

Copy link

@robinrizvi robinrizvi commented Nov 26, 2019

Able to reproduce this in 3.6.1 as well

Copy link

@jennifer-shehane jennifer-shehane commented Nov 27, 2019

@robinrizvi Please open a new issue detailing a reproducible example since this issue has been resolved. There's likely an edge case we're not handling that we will need to address separately.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Nov 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants