-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.js
72 lines (70 loc) · 2.04 KB
/
cypress.config.js
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
62
63
64
65
66
67
68
69
70
71
72
const { defineConfig } = require("cypress");
const allureWriter = require('@shelex/cypress-allure-plugin/writer');
const xlsx = require("node-xlsx").default;
const fs = require("fs");
const path = require("path");
const csv = require('@fast-csv/parse')
const { writeToPath } = require('@fast-csv/format');
module.exports = defineConfig({
e2e: {
watchForFileChanges: false,
"video": true,
"specPattern": "cypress/e2e",
// defaultCommandTimeout: 30000,
// screenshotOnRunFailure: false,
setupNodeEvents(on, config) {
on("task", {
// Read excel file
readExcel({ filePath }) {
return new Promise((resolve, reject) => {
try {
const jsonData = xlsx.parse(fs.readFileSync(filePath));
resolve(jsonData);
} catch (e) {
reject(e);
}
})
},
// Read excel file
writeExcel({ filePath, sheetName, data }) {
var buffer = xlsx.build([{ name: sheetName, data: data }]);
fs.writeFile(filePath, buffer, "binary", function (err) {
if (err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
return null;
},
// Read csv file
readCSV({ filePath }) {
return new Promise(resolve => {
let dataArray = [];
csv.parseFile(filePath, { headers: true })
.on('data', (data) => {
dataArray.push(data)
})
.on('end', () => {
resolve(dataArray)
})
})
},
// write csv file
writeToCSV({ filePath, csvData }) {
writeToPath(path.resolve(__dirname, filePath), csvData)
return null;
}
});
allureWriter(on, config);
return config;
}
},
// reporter: 'mochawesome',
// reporterOptions: {
// reportDir: 'cypress/results',
// overwrite: false,
// html: false,
// json: true,
// },
});