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

"Cannot read property '__error' of null" for a pre-configured route returning 500 #7620

Closed
travikk opened this issue Jun 8, 2020 · 1 comment
Labels
type: duplicate This issue or pull request already exists

Comments

@travikk
Copy link

travikk commented Jun 8, 2020

Current behavior:

I have a route configured in the following way:

cy.route({
         delay: 1000,
         status: 500,
         method: 'POST',
         url: `/sillyPath/blablabla/`,
         response: {},
         headers: {
            'Content-Type': 'application/grpc-web+proto',
         },
      })

When the application makes request, it obviously fails and I have a handler in the code that deals with that.
For some reason, Cypress runner sees a problem and throws the following error:

TypeError: The following error originated from your application code, not from Cypress.

  > Cannot read property '__error' of null

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
    at XMLHttpRequest._getFixtureError (http://localhost:3000/__cypress/runner/cypress_runner.js:163165:22)
    at onLoadFn (http://localhost:3000/__cypress/runner/cypress_runner.js:162015:27)
    at XMLHttpRequest.<anonymous> (http://localhost:3000/__cypress/runner/cypress_runner.js:161999:25)
From previous event:

That line, maps to the following code in cypress_runner.js:

{
    key: "_getFixtureError",
    value: function _getFixtureError() {
      var body = this.response && this.response.body;
      var err = body.__error; // this causes issue as body is null !

      if (body && err) {
        return err;
      }
    }
  }

Looks like that code should perhaps check if the response.body is null first before trying to access __error?
The net result is that my test is marked as failed, which is incorrect.

Desired behavior:

When I preconfigure a route to return an error, cypress handles it without failing the test.

Versions

Cypress: 3.7.0
OS: Windows/Linux

@jennifer-shehane
Copy link
Member

Duplicate of #7518 - this will be fixed in our next release.

@jennifer-shehane jennifer-shehane added the type: duplicate This issue or pull request already exists label Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants