-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcypress.config.ts
54 lines (53 loc) · 1.5 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
import { defineConfig } from "cypress";
import { execSync } from "child_process";
import { unlinkSync } from "fs";
export default defineConfig({
e2e: {
retries: {
runMode: 3,
openMode: 0,
},
baseUrl: "http://localhost:3000",
projectId: "yshv48",
reporterOptions: {
mochaFile: "bin/cypress/junit-[hash].xml",
testCaseSwitchClassnameAndName: true,
},
supportFile: "cypress/support/e2e.ts",
specPattern: "cypress/integration/**/*.ts",
viewportWidth: 1920,
viewportHeight: 1080,
setupNodeEvents(on) {
on("before:run", () => {
try {
execSync("yarn evg-db-ops --dump");
} catch (e) {
console.error(e);
}
});
on("after:run", () => {
try {
execSync("yarn evg-db-ops --clean-up");
} catch (e) {
console.error(e);
}
});
on("after:spec", (_, results) => {
// Delete videos for passing runs. From Cypress docs:
// https://docs.cypress.io/app/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests
if (results && results.video) {
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === "failed"),
);
if (!failures) {
try {
unlinkSync(results.video);
} catch {
console.log("unlinkSync failed. Continuing...");
}
}
}
});
},
},
});