-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
65 lines (62 loc) · 2.07 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
const { defineConfig } = require('cypress')
const decompress = require('decompress');
const path = require("path");
const fs = require("fs-extra");
const { rmdir } = require('fs')
const neatCsv = require('neat-csv')
function getConfigurationFileByEnvName(env) {
const fileLocation = path.resolve("cypress/config", `${env}.json`);
console.log(`BAT: Using ${env} config. Set appropriate parameters here - cypress/config/${env}.json, otherwise the tests will fail.`)
return fs.readJson(fileLocation);
}
const unzip = ({ path, file }) => decompress(path + file, path + '/unzip/' + file.replace('.zip', ''))
module.exports = defineConfig({
reusability: true,
video: false,
reporter: 'junit',
reporterOptions: {
mochaFile: 'cypress/report/results-[hash].xml',
toConsole: true,
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
on('task', {
'unzipping': unzip,
})
on('task', {
deleteFolder(folderName) {
console.log('deleting folder %s', folderName)
return new Promise((resolve, reject) => {
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
if (err) {
console.error(err)
return reject(err)
}
resolve(null)
})
})
}})
on('task', {
deleteFile(fileName){
return fs.unlinkSync(fileName), null
}
})
on('task', {
parseCsvFile: async (filePath) => {
try {
const fileContent = await fs.promises.readFile(filePath, 'utf-8');
const parsedData = await neatCsv(fileContent);
return parsedData;
} catch (error) {
throw new Error(`Failed to parse CSV file: ${error.message}`);
}
},
})
const envFile = config.env.configFile || "qa-milestone";
return getConfigurationFileByEnvName(envFile);
},
specPattern: 'cypress/tests/api/**/*.{js,jsx,ts,tsx}',
},
})