Skip to content

Saving coverage before page changes in test #69

Closed
@grantbdev

Description

@grantbdev

From my understanding, currently this plugin will only save coverage at the end of the test. Since coverage is stored on the window, if you have a test that navigates across more pages where window gets replaced, only the coverage from the last window will get saved even though different could could have been executed in the previous pages. I would like to collect coverage from every part of the app that was executed in the test.

As a workaround, I can manually save coverage using the combineCoverage task in my test when I think I am done with executing the current page and I expect the next interaction to cause the page to change. However, this is less than ideal because it is an implementation detail that interrupts the flow of the test. It may be possible that I would also miss some coverage with this approach on something like additional form submission logic.

I have attempted to add a binding to the Cypress window events described here: https://docs.cypress.io/api/events/catalog-of-events.html#Binding-to-Events

However that generates an error about returning a promise inside a promise, so I'm not sure if it's possible to use cy.task() or combineCoverage in particular with a Cypress event listener.

Does anyone have an idea how saving coverage before a page could be automated? If it's possible, would that be a feature that could be added to this plugin?

Thank you for the work on this plugin, I find it very useful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions