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

CypressError: cy.request() failed trying to load #7696

Closed
WinstonN opened this issue Jun 14, 2020 · 3 comments
Closed

CypressError: cy.request() failed trying to load #7696

WinstonN opened this issue Jun 14, 2020 · 3 comments

Comments

@WinstonN
Copy link

WinstonN commented Jun 14, 2020

I'm testing an API json response
My code looks like

describe('retrieve information for product', () => {
    // asserts
    it('with sku', () => {
      cy.request('GET', `${url}/product/list?skus=WJ12`)
        .then((response) => {
          // response.body is automatically serialised into JSON
          console.log(response)
      })
    })
  })

The API url is http://localhost:8080/api/product/list?skus=WJ12

Within the GUI of Cypress it works, as can be seen below
image

When running the same code in the CLI it fails with

  test the product api
    ✓ loads the product api (48ms)
    retrieve information for product
      1) with sku


  1 passing (940ms)
  1 failing

  1) test the product api
       retrieve information for product
         with sku:
     CypressError: `cy.request()` failed trying to load:

http://localhost:8080/api/product/list?skus=WJ12

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > Error: connect ECONNREFUSED 127.0.0.1:8080

I have tested this in
Cypress 4.7.0
Cypress 4.8.0

Can you see if I am doing anything wrong here?

@WinstonN
Copy link
Author

I found the issue. I'm running cypress cli in a docker, and this docker instance, does not recognise the location of the API
Running it locally works, as expected

  test the product api
    ✓ loads the product api
    retrieve information for product
      ✓ with sku (1663ms)


  2 passing (2s)

Closing this issue

@EliasSalom
Copy link

I found the issue. I'm running cypress cli in a docker, and this docker instance, does not recognise the location of the API Running it locally works, as expected

  test the product api
    ✓ loads the product api
    retrieve information for product
      ✓ with sku (1663ms)


  2 passing (2s)

Closing this issue

how do you fix this issue? because I have the same one when I try to test on the GitHub action

image

@Duccem
Copy link

Duccem commented Apr 26, 2024

I found the issue. I'm running cypress cli in a docker, and this docker instance, does not recognise the location of the API Running it locally works, as expected

  test the product api
    ✓ loads the product api
    retrieve information for product
      ✓ with sku (1663ms)


  2 passing (2s)

Closing this issue

how do you fix this issue? because I have the same one when I try to test on the GitHub action

image

You found a solution? i have the same issue

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

3 participants