-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
56 lines (54 loc) · 2.04 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
import { defineConfig } from "cypress";
import { writeFileSync, unlink } from "fs";
import * as XLSX from "xlsx";
import * as path from "path";
import { configureAllureAdapterPlugins } from "@mmisty/cypress-allure-adapter/plugins";
import dotenv from "dotenv";
dotenv.config();
export default defineConfig({
projectId: process.env.CYPRESS_PROJECT_ID,
reporter: "cypress-mochawesome-reporter",
e2e: {
baseUrl: "https://opensource-demo.orangehrmlive.com",
setupNodeEvents(on, config) {
// implement node event listeners here
on("task", {
convertXlsxToJson(args: [string, boolean]) {
return new Promise((resolve, reject) => {
const [filePath, isOriginalFile] = args;
const workbook = XLSX.readFile(filePath); // read the file
const worksheet = workbook.Sheets[workbook.SheetNames[0]]; // get the first worksheet
const jsonData = XLSX.utils.sheet_to_json(worksheet); // convert the worksheet to JSON
const fileName = path.basename(filePath, ".xlsx"); // get the file name without the extension
const jsonFilePath = `cypress/fixtures/${
fileName + (isOriginalFile ? "Original" : "")
}.json`; // create the json file path
writeFileSync(jsonFilePath, JSON.stringify(jsonData)); // write the json data to the file
resolve(jsonFilePath);
});
},
deleteFile(filePath: string) {
return new Promise((resolve, reject) => {
unlink(filePath, (err) => {
if (err) {
console.error(err);
return reject(err);
}
resolve(null);
});
});
},
});
require("cypress-mochawesome-reporter/plugin")(on);
require("@cypress/grep/src/plugin")(config);
configureAllureAdapterPlugins(on, config);
return config;
},
env: {
allure: true,
allureAttachRequests: true,
allureShowDuplicateWarn: true,
},
screenshotOnRunFailure: true,
},
});