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

allow disable of DOM snapshots for stubs and spies #3849

Closed
kuceb opened this issue Mar 29, 2019 · 8 comments · Fixed by #3968
Closed

allow disable of DOM snapshots for stubs and spies #3849

kuceb opened this issue Mar 29, 2019 · 8 comments · Fixed by #3968
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory

Comments

@kuceb
Copy link
Contributor

kuceb commented Mar 29, 2019

I use a lot of spies and stubs, and don't need a DOM snapshot every time a spied function is called, since a DOM snapshot is memory/CPU intensive

We should be able to disable the snapshot similar to how we can disable the log:

cy.stub().log(false)
cy.stub().snapshot(false)
@bahmutov
Copy link
Contributor

bahmutov commented Mar 29, 2019 via email

@jennifer-shehane
Copy link
Member

cy.stub().log(false)

Does this work?? This is not an intended use of .log() as far as I understand it. .log() is a parent command meant to be directly chained off of cy and should log what is passed in as an arg, I don't think this would affect the cy.stub() logging.

Aside from this, I would advocate for extending the options of most of our commands to allow for snapshot: false, just as they allow for log: false. See blur for example: https://on.cypress.io/blur#Arguments

Although, I think that the true win here should be fixing the snapshots to not be so memory intensive as outlined here: #2366 (comment)

@kuceb kuceb mentioned this issue Apr 15, 2019
57 tasks
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory stage: proposal 💡 No work has been done of this issue labels Apr 22, 2019
@kuceb
Copy link
Contributor Author

kuceb commented Apr 29, 2019

@jennifer-shehane .log chained off of a cypress stub/spy sets whether the stub will log or not. We do this because you cannot pass an options object to cy.stub() (theres no good way to know whats the options object and whats the stub subject)

maybe simply support a .options([..options]) method on a stub/spy instance to set the options.

here's where we create the .log function on a stub/spy https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/agents.coffee#L187

@kuceb
Copy link
Contributor Author

kuceb commented Apr 29, 2019

here's where I went ahead and implemented the .snapshot function: https://github.com/cypress-io/cypress/blob/test-retries/packages/driver/src/cy/commands/agents.coffee#L193

@monkeytroy
Copy link

Is there a way to do this at a page/window level? My page loads 50 .proto files and each one creates a log entry and dom snapshot that I don't need to see.

@jennifer-shehane
Copy link
Member

You can set the numTestsKeptInMemory to the number of tests you'd like snapshots stored for (0 if you want them off altogether).

cypress.json

{
  "numTestsKeptInMemory": 0
}

@cypress-bot cypress-bot bot added stage: work in progress and removed stage: proposal 💡 No work has been done of this issue labels Jun 16, 2020
@cypress-bot cypress-bot bot added stage: proposal 💡 No work has been done of this issue stage: work in progress and removed stage: work in progress stage: proposal 💡 No work has been done of this issue labels Jul 13, 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 Jul 14, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 10, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 10, 2020

The code for this is done in cypress-io/cypress#3968, 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 Aug 20, 2020

Released in 5.0.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants