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

Wrong parameters applied for cy.intercept() method in library. #142

Open
malibagci opened this issue Mar 19, 2024 · 3 comments
Open

Wrong parameters applied for cy.intercept() method in library. #142

malibagci opened this issue Mar 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@malibagci
Copy link

Library gives error when you define a routeMatcher like below:

cy.playback( 'GET', { url: new RegExp('^/*/'), headers: { 'Content-Type': 'application/json', }, }, { matching: { ignores: ['hostname', 'port'] }, }, );

Screenshot 2024-03-19 at 16 56 50

return cy.intercept(method, routeMatcher,... does not match with any syntax of these in Cypress Docs.

Please see: https://docs.cypress.io/api/commands/intercept#Syntax

Removing first parameter "method" fixes the issue.

Regards

@malibagci malibagci added the bug Something isn't working label Mar 19, 2024
@DigTheDoug
Copy link
Contributor

Hi @malibagci, thanks for the report. To make sure I understand, are you reporting that the note listed here about NOTE: Unlike the intercept command, the command requires a method argument is inaccurate because when using a routeMatcher the method argument is not necessary? Once you change the syntax to exclude that argument as in cy.intercept(routeMatcher) it does work for you?

@malibagci
Copy link
Author

@DigTheDoug the issue related with this line -> https://github.com/oreillymedia/cypress-playback/blob/main/lib/commands/index.js#L130

cy.intercept() does not accept method as a first parameter with routeMatcher.
maybe you can change method with url

@DigTheDoug
Copy link
Contributor

Thanks for the clarification, I see what you are saying.

@tvsbrent looks like in the intercept() method if you are using a routeMatcher argument, it needs to be the first argument or have a url as the first argument. Having the method argument is a no go. Might be worth discussing how to support since we already diverge a little bit from the intercept() method by requiring the method in all playback calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants