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 · 3 comments


3 participants
Copy link

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


This comment has been minimized.

Copy link

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


This comment has been minimized.

Copy link

lilaconlee commented Dec 13, 2018

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


This comment has been minimized.

Copy link

jennifer-shehane commented Mar 13, 2019

This was released in 3.1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.