-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
the times parameter in cy.interceptor is not respected #16821
Comments
I can verify the issue described above. I modified the example slightly so that there is a failing test (that should be passing). The test should only mock the data the first time the request matches (because it('should not intercept twice', () => {
cy.visit('https://mocki.io/fake-json-api')
cy.intercept({
method: 'POST',
times: 1,
url: /graphql$/
},
(req) => {
req.continue(res => {
res.body.data.createPublicStage.url = 'foobar'
})
}
).as('interceptor')
cy.get('#success').should('not.be.visible')
cy.get('#body').type('{ "abc": 123 }', { parseSpecialCharSequences: false })
cy.get('#create').click() // submit form that will generate url
// ✅ success msg contains mocked 'url' dats in 1st match
cy.get('#success').should('contain', 'foobar')
cy.get('#body').clear().type('{ "another": 123 }', { parseSpecialCharSequences: false })
cy.get('#create').click() // submit form that will generate url
cy.get('#success').should('not.be.visible') // make sure the succes msg rerenders
cy.get('#success').should('be.visible')
// ❗️ success msg shouldn't contain mocked 'url' data in 2nd match
.and('not.contain', 'foobar')
}) |
@sainthkh I'm seeing the exact opposite behavior, in Cypress 7.6.0. |
@jennifer-shehane It's because I didn't restart Cypress after modifying code. I fixed the problem and opened the PR. @A-ZC-Lau After fixing the I genereated the api urls with |
The code for this is done in cypress-io/cypress#17138, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
When the
times
parameter is used in RouteMatcher, it doesn't respect the limit (i.e. usingtimes: 1
will still match more than onceDesired behavior
It should only match up to the
times
specified.Test code to reproduce
Versions
7.4
The text was updated successfully, but these errors were encountered: