Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 87daa78

Browse files
committed
add note about afterEach skipped
1 parent 8631b6f commit 87daa78

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ To get typings, reference this module, for example by using `reference` comment
9393

9494
For more details read [Cypress Intelligent Completion Guide](https://on.cypress.io/intellisense)
9595

96+
## Warning
97+
98+
Skipping tests in Mocha at run-time skips the `afterEach` hooks. In this example, `afterEach` will be skipped, and `after` hook will run.
99+
100+
```js
101+
it('example', () => {
102+
cy.skipOn('mac')
103+
})
104+
afterEach(() => {
105+
// this will be skipped when a test is skipped
106+
})
107+
after(() => {
108+
// this will run even after skipping test
109+
})
110+
```
111+
96112
## Authors
97113

98114
- Kevin Old

cypress/integration/after-spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="../../index.d.ts" />
2+
// @ts-check
3+
it('runs after hooks after skipping?', () => {
4+
cy.skipOn('mac')
5+
})
6+
7+
it('does not skip this test', () => {})
8+
9+
afterEach(() => {
10+
// this will be skipped when a test is skipped
11+
cy.log('in afterEach')
12+
console.log('in afterEach for', cy)
13+
})
14+
15+
after(() => {
16+
// this will run after skipping test
17+
cy.log('in after')
18+
console.log('in after')
19+
})

0 commit comments

Comments
 (0)