-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.ts
64 lines (49 loc) · 2.25 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
import {addMatchImageSnapshotPlugin} from '@simonsmith/cypress-image-snapshot/plugin';
import { defineConfig } from 'cypress';
export default defineConfig({
watchForFileChanges: false,
viewportWidth: 1920,
viewportHeight: 1080,
e2e: {
baseUrl: 'https://poupaenergia.pt',
experimentalRunAllSpecs: true,
setupNodeEvents(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) {
// Define the browser window size on start with the viewport configurations
on('before:browser:launch', (browser: Cypress.Browser, launchOptions: Cypress.BeforeBrowserLaunchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
console.log('Google Chrome Browser');
// fullPage screenshot size is 1400x1200 on non-retina screens
// and 2800x2400 on retina screens
launchOptions.args.push(`--window-size=${config.viewportWidth},${config.viewportHeight}`);
// force screen to be non-retina (1400x1200 size)
launchOptions.args.push('--force-device-scale-factor=1');
}
if (browser.name === 'edge' && browser.isHeadless) {
console.log('MS Edge Browser');
// fullPage screenshot size is 1400x1200 on non-retina screens
// and 2800x2400 on retina screens
launchOptions.args.push(`--window-size=${config.viewportWidth},${config.viewportHeight}`);
// force screen to be non-retina (1400x1200 size)
launchOptions.args.push('--force-device-scale-factor=1');
// force screen to be retina (2800x2400 size)
// launchOptions.args.push('--force-device-scale-factor=2')
}
if (browser.name === 'electron' && browser.isHeadless) {
console.log('Electron Browser');
// fullPage screenshot size is 1400x1200
launchOptions.preferences.width = config.viewportWidth;
launchOptions.preferences.height = config.viewportHeight;
}
if (browser.name === 'firefox' && browser.isHeadless) {
console.log('Mozilla Firefox Browser');
// menubars take up height on the screen
// so fullPage screenshot size is 1400x1126
launchOptions.args.push(`--width=${config.viewportWidth}`);
launchOptions.args.push(`--height=${config.viewportHeight}`);
}
return launchOptions;
});
addMatchImageSnapshotPlugin(on);
},
},
});