-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcypress.config.ts
101 lines (99 loc) · 2.97 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
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
92
93
94
95
96
97
98
99
100
101
import { defineConfig } from 'cypress';
import * as fs from 'fs';
import * as console from 'console';
export default defineConfig({
screenshotsFolder: './gui_test_screenshots/cypress/screenshots',
screenshotOnRunFailure: true,
trashAssetsBeforeRuns: true,
videosFolder: './gui_test_screenshots/cypress/videos',
video: true,
videoCompression: false,
reporter: './node_modules/cypress-multi-reporters',
reporterOptions: {
configFile: 'reporter-config.json',
},
env: {
grepFilterSpecs: true,
HOST_API: process.env.CYPRESS_BASE_URL.replace(/console-openshift-console.apps/, 'api').concat(
':6443',
),
// LOGIN_USERNAME: process.env.CYPRESS_LOGIN_USERS.split(',')[0].split(':')[0],
// LOGIN_PASSWORD: process.env.CYPRESS_LOGIN_USERS.split(',')[0].split(':')[1],
},
fixturesFolder: 'fixtures',
defaultCommandTimeout: 30000,
retries: {
runMode: 0,
openMode: 0,
},
viewportWidth: 1440,
viewportHeight: 900,
e2e: {
setupNodeEvents(on, config) {
on(
'before:browser:launch',
(
browser = {
name: '',
family: 'chromium',
channel: '',
displayName: '',
version: '',
majorVersion: '',
path: '',
isHeaded: false,
isHeadless: false,
},
launchOptions,
) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
// Auto open devtools
launchOptions.args.push('--enable-precise-memory-info');
}
return launchOptions;
},
);
// `on` is used to hook into various events Cypress emits
on('task', {
log(message) {
console.log(message);
return null;
},
logError(message) {
console.error(message);
return null;
},
logTable(data) {
console.table(data);
return null;
},
readFileIfExists(filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8');
}
return null;
},
});
on('after:spec', (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === 'failed'),
);
if (!failures && fs.existsSync(results.video)) {
// Delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video);
}
}
});
return config;
},
supportFile: './cypress/support/e2e.js',
specPattern: 'tests/**/*.cy.{js,jsx,ts,tsx}',
numTestsKeptInMemory: 1,
testIsolation: false,
experimentalModifyObstructiveThirdPartyCode: true,
experimentalOriginDependencies: true,
experimentalMemoryManagement: true,
},
});