-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.js
91 lines (81 loc) · 2.47 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const { defineConfig } = require('cypress');
const fse = require('fs-extra');
module.exports = defineConfig({
e2e: {
defaultCommandTimeout: 10000,
pageLoadTimeout: 15000,
requestTimeout: 15000,
viewportWidth: 1280,
viewportHeight: 1024,
screenshotsFolder: 'build/screenshots',
videosFolder: 'build/videos',
retries: {
runMode: 1,
openMode: 0,
},
chromeWebSecurity: false,
env: {},
setupNodeEvents(on, config) {
on('before:browser:launch', () => {
fse.removeSync('build/');
});
on('task', {
log(message) {
console.log(message);
return null;
},
table(message) {
console.table(message);
return null;
},
saveAxeResultsToFile({ data, url }) {
const reportPath = 'build/axe/axe-report.json';
fse.readJson(reportPath, (err, jsonData) => {
if (err && err.code !== 'ENOENT') throw err;
const updatedData = jsonData || [];
updatedData.push({ url, violations: data });
fse.outputFile(
reportPath,
JSON.stringify(updatedData, null, 2),
writeErr => {
if (writeErr) throw writeErr;
console.log(`***** Report updated: ${reportPath} *****`);
},
);
});
return null;
},
});
const environmentName = config.env.environmentName || 'local';
const environmentFilename = `./cypress/environments/${environmentName}.env.json`;
try {
console.log('====== Loading %s', environmentFilename, 'file ======');
// eslint-disable-next-line import/no-dynamic-require, global-require
const settings = require(environmentFilename);
const newConfig = { ...config };
Object.keys(settings).forEach(key => {
if (key === 'env') {
newConfig.env = {
...newConfig.env,
...settings.env,
};
} else {
newConfig[key] = settings[key];
}
});
console.log(
'====== Loaded settings for environment: %s',
environmentName,
'======',
);
return newConfig;
} catch (error) {
throw new Error(
`Environment file not found. Please follow instructions in
the "Updating Environment files"
section of the README.md.`,
);
}
},
},
});