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

v7.4.0 No longer allows localhost as a RouteMatcher hostname #17015

Closed
lucitez opened this issue Jun 18, 2021 · 4 comments · Fixed by #17068
Closed

v7.4.0 No longer allows localhost as a RouteMatcher hostname #17015

lucitez opened this issue Jun 18, 2021 · 4 comments · Fixed by #17068

Comments

@lucitez
Copy link

lucitez commented Jun 18, 2021

Current behavior

cy.intercept({ hostname: 'localhost' }, (req) => { ... })

Results in

An invalid RouteMatcher was supplied to cy.intercept(). hostname must be a valid host name or domain name.

You passed: {
  "hostname": "localhost"
}

Screen Shot 2021-06-18 at 1 55 53 PM

Desired behavior

As the docs suggest (https://docs.cypress.io/api/commands/intercept#Usage), I should be able to use 'localhost' as the hostname.

// spying, dynamic stubbing, request modification, etc.
cy.intercept('/users*', { hostname: 'localhost' }, (req) => {
  /* do something with request and/or response */
})

Test code to reproduce

cy.intercept({ hostname: 'localhost' }, (req) => { ... })

Versions

Introduced in 7.4.0 in this PR #16577

Worked in 7.3.0

@sainthkh
Copy link
Contributor

sainthkh commented Jun 22, 2021

Confirmed with the code below:

it('test', () => {
  cy.intercept('/users*', { hostname: 'localhost' }, (req) => {
    /* do something with request and/or response */
  })
})

@flotwig @jennifer-shehane

The code or doc should be fixed.

@sainthkh sainthkh added stage: needs investigating Someone from Cypress needs to look at this topic: cy.intercept() labels Jun 22, 2021
@flotwig
Copy link
Contributor

flotwig commented Jun 22, 2021

@sainthkh the validation is incorrect, localhost should be permitted here.

@sainthkh sainthkh added stage: ready for work The issue is reproducible and in scope and removed stage: needs investigating Someone from Cypress needs to look at this labels Jun 23, 2021
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Jun 23, 2021
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Jul 7, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jul 12, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 12, 2021

The code for this is done in cypress-io/cypress#17068, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 20, 2021

Released in 8.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v8.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants