-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
47 lines (44 loc) · 1.17 KB
/
cypress.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import viteConfig from "./vite.config";
import { defineConfig } from "cypress";
import { rmdir, existsSync } from "fs";
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on("task", {
deleteFolder,
});
},
baseUrl: "http://localhost:3000",
},
component: {
devServer: {
framework: "react",
bundler: "vite",
viteConfig: {
...viteConfig,
},
},
setupNodeEvents(on, config) {
on("task", {
deleteFolder,
});
},
},
});
function deleteFolder(folderName: string): Promise<string> {
return new Promise((resolve, reject) => {
if (existsSync(folderName)) {
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
if (err) {
console.error(`\x1b[31mFailed to delete folder ${folderName}: ${err.message}\x1b[0m`);
return reject("Failed to delete folder");
}
console.info(`\x1b[34mFolder ${folderName} deleted successfully\x1b[0m`);
resolve("Folder deleted");
});
} else {
console.info(`\x1b[34mFolder ${folderName} does not exist\x1b[0m`);
resolve("Folder does not exist");
}
});
}