1// cypress/support/index.js
2
3function abortEarly () {
4 if ( this.currentTest.state === 'failed' ) {
5 return cy.task('shouldSkip', true);
6 }
7 cy.task('shouldSkip').then( value => {
8 if ( value ) this.skip();
9 });
10}
11
12beforeEach(abortEarly);
13afterEach(abortEarly);
14
15before(() => {
16 if ( Cypress.browser.isHeaded ) {
17 // Reset the shouldSkip flag at the start of a run, so that it
18 // doesn't carry over into subsequent runs.
19 // Do this only for headed runs because in headless runs,
20 // the `before` hook is executed for each spec file.
21 cy.task('resetShouldSkipFlag');
22 }
23});