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

Support dynamically disabling request logs via cy.intercept() #26069

Open
flotwig opened this issue Mar 9, 2023 · 5 comments
Open

Support dynamically disabling request logs via cy.intercept() #26069

flotwig opened this issue Mar 9, 2023 · 5 comments
Labels
topic: cy.intercept() type: enhancement Requested enhancement of existing feature

Comments

@flotwig
Copy link
Contributor

flotwig commented Mar 9, 2023

What would you like?

Add the ability to dynamically disable request logs in cy.intercept(), like so:

cy.intercept('/foo', (req) => {
  req.log = false
}

Why is this needed?

#25547 adds the ability to control log via StaticResponseWithOptions. However, this can only be done statically, not dynamically via an interceptor function.

The reasons why it was done this way are detailed in the original ClickUp initiative. TL;DR: dynamically setting log can cause a log to be hidden/shown asynchronously, which requires making some hard UI decisions about how to indicate this at each step.

Other

No response

@jennifer-shehane
Copy link
Member

Make sure to update the docs when this issue is closed in the future. cypress-io/cypress-documentation#5106

@SebeFromGermany
Copy link

Any updates on this?

@tuliobluz
Copy link

It would be nice to have an option to log only when there is an error.

@verheyenkoen
Copy link
Contributor

Other options are:

  • to change the signature and move the log option to a "third" options argument (or "fourth" if method or url are passed on separately), like so:
    cy.intercept({method and/or url or RouteMatcher}, {StaticResponse or RouteHandler}, { log: false })
    Currently it is a bit of an odd-one-out option in the StaticResponse object. Not sure if other intercept options would qualify for this object.
  • to add the possibility to set the RouteHandler via an option in StaticResponse, like so:
    cy.intercept({method and/or url or RouteMatcer}, { handler: (req) => { ... }, log: false })

Obviously thorough analysis is necessary to check if these signatures are not dubiously conflicting with the existing signature.

@pbassut
Copy link

pbassut commented Oct 19, 2024

Argh, also needed this to make my logs look a bit prettier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cy.intercept() type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

6 participants