forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcypress.config.js
More file actions
84 lines (78 loc) · 3.09 KB
/
Copy pathcypress.config.js
File metadata and controls
84 lines (78 loc) · 3.09 KB
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
/* eslint-disable no-undef */
const { defineConfig } = require('cypress');
const fs = require('fs');
const path = require('path');
module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
viewportHeight: 800,
viewportWidth: 1800,
numTestsKeptInMemory: 5,
videoCompression: false,
allowCypressEnv: false,
// Enable before:run event in open mode (cypress open) for local development.
// Required for on('before:run'...) hook (see #10026) to capture DB state.
// Note: after:run is only used in CI (run mode). Can be removed if Cypress defaults
// to enabling these events or if we no longer need the before:run hook.
experimentalInteractiveRunEvents: true,
// See: https://docs.cypress.io/app/references/experiments#Experimental-Flake-Detection-Features
retries: {
experimentalStrategy: 'detect-flake-and-pass-on-threshold',
experimentalOptions: {
maxRetries: 3,
passesRequired: 1,
},
openMode: false,
runMode: true,
},
setupNodeEvents(on, _config) {
// Check for Cypress build marker
const markerPath = path.resolve(__dirname, 'tmp/.cypress-build-marker');
if (!fs.existsSync(markerPath)) {
const errorMsg = [
'',
'================================================================================',
'❌ ERROR: Webpack was not built with CYPRESS=true',
'================================================================================',
'',
'Debug notifications will appear in the UI and may block elements.',
'',
'To fix this, rebuild webpack with:',
' CYPRESS=true bin/webpack',
'',
'================================================================================',
'',
].join('\n');
console.error(errorMsg);
throw new Error('Webpack was not built with CYPRESS=true. See console for details');
}
// Capture DB state once before entire test run
on('before:run', async () => {
await fetch('http://localhost:3000/__e2e__/command', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'db_state', options: 'capture' })
});
});
on('after:spec', (spec, results) => {
// Delete the video on CI if the spec passed and no tests retried
if (process.env.CI && results && results.video && fs.existsSync(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.unlinkSync(results.video);
}
}
});
on('before:browser:launch', (browser = {}, launchOptions) => {
console.log('Launching browser:', browser.name);
if (browser.name === 'chrome') {
launchOptions.args.push('--disable-features=AutofillServerCommunication');
}
return launchOptions;
});
},
},
});