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

Add new plugin events 'before:spec', 'after:spec', 'before:run', 'after:run' #6665

Closed
chrisbreiding opened this issue Mar 6, 2020 · 3 comments
Assignees
Labels
topic: plugins ⚙️ type: feature New feature that does not currently exist

Comments

@chrisbreiding
Copy link
Contributor

chrisbreiding commented Mar 6, 2020

Add four new events that fire in the plugins file:

  • before:run: Fires before the run starts, with details about the run.
  • before:spec: Fires before a spec file is run, with details about the spec file.
  • after:spec: Fires after a spec file and its tests run, with details about the spec file and its test results.
  • after:run: Fires after the run finishes, with the results of the run.

In interactive mode, the behavior is slightly different, since there isn't a discrete 'run' and specs can be re-run at will:

  • before:run fires when opening a project.
  • before:spec fires when the browser opens.
  • after:spec fires when the browser closes (and may not fire at all (if, for example, you force quit Cypress).
  • after:run fires when you close the project (and may not fire at all (if, for example, you force quit Cypress).

The after:* events will only receive results in run mode, since there's no way to aggregate results from interactive mode.

Note: this is take 2 on this previous issue: #2286. This will be able to be released in the next feature release instead of waiting for the next major version.

@amitzur
Copy link

amitzur commented Jun 25, 2020

Is there a way for a plugin to detect if it's running in interactive mode or run mode?

@denis-domanskii
Copy link

denis-domanskii commented Nov 16, 2020

Hi @chrisbreiding, please don't forget about parallel run. I'll expect that run:start and run:end will be called once per run, not once on each parallel machine - I have explained my issue in #9196. Thank you for working on it :)

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Dec 23, 2020

Released in 6.2.0.

You can now listen to before:run, after:run, before:spec and after:spec events in the plugins file when setting the experimentalRunEvents configuration option to true. See the appropriate events doc for more details: https://on.cypress.io/writing-a-plugin#List-of-events

The use of the 'before:spec', 'after:spec', 'before:run', 'after:run' are not triggered in interactive mode currently. If you have a use case for needing these to run during cypress open, please open a new issue requesting this feature and explaining your use case.

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

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 23, 2020
@jennifer-shehane jennifer-shehane removed the stage: ready for work The issue is reproducible and in scope label Dec 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: plugins ⚙️ type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

5 participants