diff --git a/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts b/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts index 6c6806b83b7e4cd4e2d8dbfcd48976a506dc6774..d92b9e80d3c05c57f3e62671449e84d4ecd40f5b 100644 --- a/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts +++ b/goofy-client/apps/goofy-e2e/src/support/cypress-tasks.ts @@ -1,3 +1,4 @@ +import { rmdir } from 'fs'; import { Long, MongoClient, ObjectId } from 'mongodb'; const Binary = require('mongodb').Binary; @@ -43,7 +44,16 @@ module.exports = (on: any, config: any) => { console.log('dropUserManagerCollections: ', collections); dropUserManagerCollectionsFromDatabase(config, collections); return 0; - } + }, + countFiles(folderName:string) { + console.log('counting files in folder %s', folderName); + return countFiles(folderName); + }, + deleteFolder(folderName:string) { + console.log('deleting folder %s', folderName); + deleteFolder(folderName); + return 0; + }, }); // Workaround für Angular 13 und Cypress mit Webpack 4, @@ -295,4 +305,28 @@ function dropCollections(databaseUrl, databaseName, collections){ }); } }); +} + +function countFiles(folderName:string): Promise<number> { + return new Promise((resolve, reject) => { + fs.readdir(folderName, (err, files) => { + if (err) { + console.error(err) + return reject(err) + } + resolve(files.length) + }) + }) +} + +function deleteFolder(folderName:string): void { + new Promise((resolve, reject) => { + rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => { + if (err) { + console.error(err) + return reject(err) + } + resolve(null) + }) + }) } \ No newline at end of file