66
77import { configureNextcloud , docker , getContainer , getContainerName , runExec , runOcc , startNextcloud , stopNextcloud , waitOnNextcloud } from '@nextcloud/e2e-test-server'
88import { defineConfig } from 'cypress'
9- import { removeDirectory } from 'cypress-delete-downloads-folder'
109import cypressSplit from 'cypress-split'
1110import vitePreprocessor from 'cypress-vite'
12- import { existsSync } from 'node:fs'
11+ import { existsSync , rmdirSync } from 'node:fs'
1312import { dirname , join , resolve } from 'node:path'
1413import { fileURLToPath } from 'node:url'
1514import { nodePolyfills } from 'vite-plugin-node-polyfills'
@@ -68,8 +67,6 @@ export default defineConfig({
6867 plugins : [ nodePolyfills ( ) ] ,
6968 } ) )
7069
71- on ( 'task' , { removeDirectory } )
72-
7370 // This allows to store global data (e.g. the name of a snapshot)
7471 // because Cypress.env() and other options are local to the current spec file.
7572 const data : Record < string , unknown > = { }
@@ -81,6 +78,17 @@ export default defineConfig({
8178 getVariable ( { key } ) {
8279 return data [ key ] ?? null
8380 } ,
81+ // allow to clear the downloads folder
82+ deleteFolder ( path : string ) {
83+ try {
84+ if ( existsSync ( path ) ) {
85+ rmdirSync ( path , { maxRetries : 10 , recursive : true } )
86+ }
87+ return null
88+ } catch ( error ) {
89+ throw Error ( `Error while deleting ${ path } . Original error: ${ error } ` )
90+ }
91+ } ,
8492 } )
8593
8694 // Disable spell checking to prevent rendering differences
0 commit comments