forked from Altinn/app-frontend-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.js
46 lines (42 loc) · 1.32 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
const { defineConfig } = require('cypress');
const path = require('node:path');
const fs = require('node:fs/promises');
// noinspection JSUnusedGlobalSymbols
module.exports = defineConfig({
e2e: {
setupNodeEvents(_, config) {
const validEnvironments = ['local', 'at21', 'at22', 'tt02'];
if (validEnvironments.includes(config.env.environment)) {
return getConfigurationByFile(config.env.environment);
}
throw new Error(`Unknown environment "${config.env.environment}"
Valid environments are:
- ${validEnvironments.join('\n- ')}`);
},
specPattern: 'test/e2e/integration/',
supportFile: 'test/e2e/support/index.ts',
},
video: false,
fixturesFolder: 'test/e2e/fixtures',
downloadsFolder: 'test/downloads',
screenshotOnRunFailure: true,
screenshotsFolder: 'test/screenshots',
trashAssetsBeforeRuns: true,
videosFolder: 'test/videos',
viewportHeight: 768,
viewportWidth: 1536,
requestTimeout: 10000,
defaultCommandTimeout: 8000,
reporter: 'junit',
reporterOptions: {
mochaFile: 'test/reports/result-[hash].xml',
},
retries: {
runMode: 1,
openMode: 0,
},
});
async function getConfigurationByFile(file) {
const pathToJsonDataFile = path.resolve('test/e2e/config', `${file}.json`);
return JSON.parse((await fs.readFile(pathToJsonDataFile)).toString());
}