cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Cannot specify port on intercept

Open jonoreilly opened this issue 4 years ago • 5 comments

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

jonoreilly avatar Aug 09 '21 10:08 jonoreilly

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 avatar May 15 '23 16:05 cypress-app-bot

This issue has been closed due to inactivity.

cypress-app-bot avatar May 31 '23 20:05 cypress-app-bot

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

bspot avatar Aug 27 '23 09:08 bspot

Having the same issue with cypress 13.8.0

mgaonach avatar Apr 29 '24 15:04 mgaonach

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 avatar Nov 18 '24 02:11 cypress-app-bot

This issue has been closed due to inactivity.

cypress-app-bot avatar Dec 02 '24 02:12 cypress-app-bot