@@ -108,19 +108,20 @@ failing tests.
108
108
:::cypress-config-plugin-example
109
109
110
110
``` ts
111
- // need to install the "del" module as a dependency
112
- // npm i del --save-dev
113
- import del from ' del'
111
+ import fs from ' fs'
114
112
```
115
113
116
114
``` ts
117
- on (' after:spec' , (spec , results ) => {
118
- if (results && results .stats .failures === 0 && results .video ) {
119
- // `del()` returns a promise, so it's important to return it to ensure
120
- // deleting the video is finished before moving on
121
- del (results .video )
115
+ on (
116
+ ' after:spec' ,
117
+ (spec : Cypress .Spec , results : CypressCommandLine .RunResult ) => {
118
+ // Do we have failures?
119
+ if (results && results .video && results .stats .failures === 0 ) {
120
+ // delete the video if the spec passed
121
+ fs .unlinkSync (results .video )
122
+ }
122
123
}
123
- } )
124
+ )
124
125
```
125
126
126
127
:::
@@ -137,25 +138,25 @@ retry attempts when using Cypress [test retries](/guides/guides/test-retries).
137
138
:::cypress-config-plugin-example
138
139
139
140
``` ts
140
- // need to install these dependencies
141
- // npm i lodash del --save-dev
142
- import _ from ' lodash'
143
- import del from ' del'
141
+ import fs from ' fs'
144
142
```
145
143
146
144
``` ts
147
- on (' after:spec' , (spec , results ) => {
148
- if (results && results .video ) {
149
- // Do we have failures for any retry attempts?
150
- const failures = _ .some (results .tests , (test ) => {
151
- return _ .some (test .attempts , { state: ' failed' })
152
- })
153
- if (! failures ) {
154
- // delete the video if the spec passed and no tests retried
155
- del (results .video )
145
+ on (
146
+ ' after:spec' ,
147
+ (spec : Cypress .Spec , results : CypressCommandLine .RunResult ) => {
148
+ if (results && results .video ) {
149
+ // Do we have failures for any retry attempts?
150
+ const failures = results .tests .some ((test ) =>
151
+ test .attempts .some ((attempt ) => attempt .state === ' failed' )
152
+ )
153
+ if (! failures ) {
154
+ // delete the video if the spec passed and no tests retried
155
+ fs .unlinkSync (results .video )
156
+ }
156
157
}
157
158
}
158
- } )
159
+ )
159
160
```
160
161
161
162
:::
0 commit comments