Peter Boomsma
Peter Boomsma

Reputation: 9808

Before/After spec not working as expected

In my Cypress configuration I have a before and after spec:

on('before:spec', () => {
    console.log('before spec');
});
on('after:spec', () => {
    console.log('after spec');
});

When I do cypress:run I see the before and after logged with each spec. But when I run cypress:open I see a the before spec when I open the Cypress client, not when I open the spec. The after spec is also not logged when the test is finished, but rather when the Cypress client is closed.

Upvotes: 0

Views: 727

Answers (1)

Beysinvader
Beysinvader

Reputation: 51

From the documentation:

The after:spec event fires after a spec file is run. When running cypress via cypress open, the event will fire when the browser closes.

and

When running via cypress open, the after:spec event only fires if the experimentalInteractiveRunEvents flag is enabled.

Upvotes: 2

Related Questions