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

cy.intercept does not work with lowercase HTTP methods #9313

Closed
bahmutov opened this issue Nov 24, 2020 · 2 comments · Fixed by #9324
Closed

cy.intercept does not work with lowercase HTTP methods #9313

bahmutov opened this issue Nov 24, 2020 · 2 comments · Fixed by #9324

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Nov 24, 2020

Cypress v6.0.0 with new cy.intercept should match the behavior of cy.route

  • it should understand both lowercase and uppercase HTTP methods

Reproducible example from https://github.com/cypress-io/cypress-example-recipes/tree/get-vs-GET

file examples/stubbing-spying__intercept/cypress/integration/spy-on-fetch-spec.js

describe.only('get vs GET', () => {
  context('cy.route', () => {
    let polyfill

    // grab fetch polyfill from remote URL, could be also from a local package
    before(() => {
      const polyfillUrl = 'https://unpkg.com/unfetch/dist/unfetch.umd.js'

      cy.request(polyfillUrl)
      .then((response) => {
        polyfill = response.body
      })
    })

    it('works with GET', function () {
      cy.server()
      cy.route('get', '/favorite-fruits').as('fruits')
      cy.visit('/', {
        onBeforeLoad (win) {
          delete win.fetch
          win.eval(polyfill)
          win.fetch = win.unfetch
        },
      })

      cy.wait('@fruits')
    })

    it('works with get', function () {
      cy.server()
      cy.route('get', '/favorite-fruits').as('fruits')
      cy.visit('/', {
        onBeforeLoad (win) {
          delete win.fetch
          win.eval(polyfill)
          win.fetch = win.unfetch
        },
      })

      cy.wait('@fruits')
    })
  })

  context('cy.intercept', () => {
    it('works with GET', function () {
      cy.intercept('GET', '/favorite-fruits').as('fruits')
      cy.visit('/')

      cy.wait('@fruits')
    })

    // NOTE: does NOT work with "get"
    it.skip('works with get', function () {
      cy.intercept('get', '/favorite-fruits').as('fruits')
      cy.visit('/')

      cy.wait('@fruits')
    })
  })
})

if we run just the skipped test

it.only('works with get', function () {
  cy.intercept('get', '/favorite-fruits').as('fruits')
  cy.visit('/')

  cy.wait('@fruits')
})

The wait times out

The network call does happen

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Nov 24, 2020
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Nov 25, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Nov 30, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Nov 30, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 30, 2020

The code for this is done in cypress-io/cypress#9324, 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 Nov 30, 2020

Released in 6.0.1.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 30, 2020
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.

3 participants
@jennifer-shehane @bahmutov and others