-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
61 lines (58 loc) · 1.52 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { defineConfig } from "cypress";
import { rmdir, existsSync } from "fs";
import path from "path";
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on("task", {
deleteFolder,
});
},
baseUrl: "http://localhost:3000",
defaultBrowser: "chrome",
},
component: {
defaultBrowser: "chrome",
devServer: {
framework: "react",
bundler: "vite",
viteConfig: {
server: {
host: true,
port: 3000,
},
build: {
outDir: "build", // Changed output folder, like in CRA
},
resolve: {
alias: {
"@components": path.resolve(__dirname, "src/components"),
"@hooks": path.resolve(__dirname, "src/hooks"),
},
},
},
},
setupNodeEvents(on, config) {
on("task", {
deleteFolder,
});
},
},
});
function deleteFolder(folderName: 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");
}
});
}