@@ -108,19 +108,20 @@ failing tests.
108108:::cypress-config-plugin-example
109109
110110``` 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'
114112```
115113
116114``` 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+ }
122123 }
123- } )
124+ )
124125```
125126
126127:::
@@ -137,25 +138,25 @@ retry attempts when using Cypress [test retries](/guides/guides/test-retries).
137138:::cypress-config-plugin-example
138139
139140``` 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'
144142```
145143
146144``` 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+ }
156157 }
157158 }
158- } )
159+ )
159160```
160161
161162:::
0 commit comments