cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.01k stars 3.18k forks source link

Cannot specify port on intercept #17653

Open jonoreilly opened 3 years ago

jonoreilly commented 3 years ago

Current behavior

Hi there, I'm having an issue where if I specify the port on cy.intercept it won’t match the request. This is what my code looks like:

cy.intercept(
  { 
    method: 'POST', 
    pathname: '/api/my-work-list', 
    hostname: 'localhost', 
    port: 8100,
  }, { 
    body: 'Created successfully',
  }
).as('POST-createWorklist')
Screenshot 2021-08-09 at 12 46 39 Screenshot 2021-08-09 at 12 29 28

When I don’t specify the port it works correctly:

cy.intercept(
  { 
    method: 'POST', 
    pathname: '/api/my-work-list', 
    hostname: 'localhost',
  }, { 
    body: 'Created successfully',
  }
).as('POST-createWorklist')
Screenshot 2021-08-09 at 12 45 49 Screenshot 2021-08-09 at 12 32 56

The expected behaviour is that it will only match the calls to the port if it is specified, as described in the documentation.

I'm using Cypress version 8.2.0.

Thanks in advance.

Desired behavior

The expected behaviour is that it will only match the calls to the port if it is specified, as described in the documentation.

Test code to reproduce

cy.intercept(
  { 
    method: 'POST', 
    pathname: '/api/my-work-list', 
    hostname: 'localhost', 
    port: 8100,
  }, { 
    body: 'Created successfully',
  }
).as('POST-createWorklist')

Cypress Version

8.2.0

Other

No response

cypress-app-bot commented 1 year ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 1 year ago

This issue has been closed due to inactivity.

bspot commented 1 year ago

I'm also experiencing this. Matching on port appears to simply not work.

mgaonach commented 6 months ago

Having the same issue with cypress 13.8.0