Also run lifecycle hooks (before:run, after:run, before:spec, after:spec) in plugins while in interactive mode
See original GitHub issueWhat would you like?
As described in the last comment of issue 6665 the lifecycle hooks before:run
, after:run
, before:spec
and after:spec
in a plugin don’t run while in interactive mode.
I don’t really get the reasoning behind this choice. Maybe this is hard to do technically. But I would like these events to be triggered when running in any mode.
Why is this needed?
The reason I would like to use these events is to subscribe and unsubscribe to some of my own events that get triggered by my system to do some integration tests. Another use case I would assume is to prep some data or clear some data that is managed by a plugin, so not to use the beforeEach and stuff of the tests themself but from the plugin.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Catalog of Events
Cypress emits a series of events as it runs in your browser. ... whether Cypress is in interactive mode (running via cypress open...
Read more >Compiler Hooks
Executes a plugin during watch mode after a new compilation is triggered but before the compilation is actually started. Callback Parameters: compiler ...
Read more >What are Cypress Hooks and How to use Hooks in Cypress?
How to define Cypress hooks, include/exclude/ define a TestSuite and ... be defined and when they will invoke during the test life cycle....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @jennifer-shehane, it works but apparently not for re-runs or when running multiple specs. I’m running v7.3.0
I also find it surprising and disappointing that these events aren’t run when triggering a re-run in the interactive mode (especially a year later). It makes the interactive mode essentially useless if you rely on the hooks for any setup/teardown.
The obvious thing, to me, is to treat any re-run, whether it’s a single spec or all, as a non-interactive run, which should answer all the questions @jennifer-shehane posed above. I dislike any solution that makes the interactive case different from the non — this is not where I want to spend mental energy on extra complexity in my development process.