question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Also run lifecycle hooks (before:run, after:run, before:spec, after:spec) in plugins while in interactive mode

See original GitHub issue

What 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:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
KrekkieDcommented, May 17, 2021

Hi @jennifer-shehane, it works but apparently not for re-runs or when running multiple specs. I’m running v7.3.0

0reactions
cameroncommented, Aug 30, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found