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

Interceptor overrides are disabled #120

Closed
aayvazyan-tgm opened this issue Sep 30, 2021 · 6 comments
Closed

Interceptor overrides are disabled #120

aayvazyan-tgm opened this issue Sep 30, 2021 · 6 comments

Comments

@aayvazyan-tgm
Copy link

If interceptors override each other, then the newest matching interceptor should be called.
Somehow this plugin disables this order.

The workaround is to disable/remove 'cy:intercept' in options.collectTypes

@archfz
Copy link
Owner

archfz commented Sep 30, 2021

Can you check here https://github.com/archfz/cypress-terminal-report/blob/master/src/collector/LogCollectCypressIntercept.js . I don't see how else this should be done, we are calling the previous overwrite.

@aayvazyan-tgm
Copy link
Author

The code looks perfectly fine. Still, it seems to cause a side effect within cypress.

@archfz
Copy link
Owner

archfz commented Oct 2, 2021

Can you provide reproduction steps?

@aayvazyan-tgm
Copy link
Author

aayvazyan-tgm commented Oct 4, 2021

    beforeEach(() => {
      cy.intercept("GET", "https://example.cypress.io/**", {fixture: "example.html"})
    })

    it('Should show test', () => {
      cy.intercept("GET", "https://example.cypress.io/**", {fixture: "example2.html"})

      cy.visit('https://example.cypress.io/todo')
      cy.contains("Interceptor 2").should('be.visible')
    })

    it('Should show test', () => {
      cy.intercept("GET", "https://example.cypress.io/**", {body: "<html lang='en'>Interceptor 3</html>"})

      cy.visit('https://example.cypress.io/todo')
      cy.contains("Interceptor 3").should('be.visible')
    })

image

I have setup a minimal project with this bug:
https://github.com/aayvazyan-tgm/cypress-logger-interceptor-bug

archfz added a commit that referenced this issue Oct 4, 2021
archfz added a commit that referenced this issue Oct 4, 2021
@archfz
Copy link
Owner

archfz commented Oct 4, 2021

Yeah good catch. The issue is that somehow the return value of the original handler function of cy.intercept being override gives a return value, which if not returned in the new handler will cause this issue. Now the strange part that this issue reproduces only in GUI, so it cannot be tested for easily.

archfz added a commit that referenced this issue Oct 4, 2021
#120: Fix issue with cy.intercept
@archfz
Copy link
Owner

archfz commented Oct 4, 2021

Fixed in 3.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants