This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.js
76 lines (70 loc) · 2.81 KB
/
configure.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
import { defineConfig } from 'cypress';
import path from 'path';
import { setupTypescript } from './plugins/typescript';
import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter';
import * as tasks from './tasks';
import { disableChromeGPU } from './plugins/disable_gpu';
import { coverageParallel } from './plugins/coverage_parallel.js';
import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin';
import {deleteVideos} from './plugins/delete_videos.js';
const LSF_PORT = process.env.LSF_PORT ?? '3000';
const COLLECT_COVERAGE = process.env.COLLECT_COVERAGE === 'true' || process.env.COLLECT_COVERAGE === '1';
const localPath = p => path.resolve(process.cwd(), p);
/**
* Override Cypress settings
* @param {(config: Cypress.ConfigOptions) => Cypress.ConfigOptions} configModifier
* @param {Cypress.EndToEndConfigOptions["setupNodeEvents"]?} setupNodeEvents
*/
export default function(configModifier, setupNodeEvents) {
/** @type {Cypress.ConfigOptions<any>} */
const defaultConfig = {
// Assets configuration
supportFolder: localPath('./cypress/support/'),
videosFolder: localPath('./output/video'),
screenshotsFolder: localPath('./output/screenshots'),
downloadsFolder: localPath('./output/downloads'),
fixturesFolder: localPath('./fixtures'),
trashAssetsBeforeRuns: false, // Kills ability to run in parallel, must be off
videoUploadOnPasses: false,
videoCompression: false,
experimentalInteractiveRunEvents: true,
env: {
coverage: COLLECT_COVERAGE,
},
e2e: {
baseUrl: `http://localhost:${LSF_PORT}`,
specPattern: './specs/**/*.cy.ts',
viewportWidth: 1600,
viewportHeight: 900,
// output config
setupNodeEvents(on, config) {
on('before:browser:launch', (browser = null, launchOptions) => {
if (browser.name === 'chrome') {
// Force sRGB color profile to prevent color mismatch in CI vs local runs
launchOptions.args.push('--force-color-profile=srgb');
return launchOptions;
}
});
deleteVideos(on, config);
addMatchImageSnapshotPlugin(on, config);
// Allows collecting coverage
coverageParallel(on, config);
on('task', { ...tasks });
// Gives a step-by-step output for failed tests in headless mode
installLogsPrinter(on, {
outputVerbose: false,
});
// Allows compiling TS files from node_modules (this package)
setupTypescript(on, config);
setupNodeEvents?.(on, config);
// When running in headless on the CI, there's no GPU acceleration available
disableChromeGPU(on);
return config;
},
},
};
const finalConfig = configModifier
? configModifier(defaultConfig)
: defaultConfig;
return defineConfig(finalConfig);
}