forked from cypress-io/cypress-example-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
62 lines (50 loc) · 1.8 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* eslint-disable no-console */
const { defineConfig } = require('cypress')
module.exports = defineConfig({
fixturesFolder: false,
e2e: {
supportFile: false,
setupNodeEvents (on, config) {
// configure plugins here
on('task', {
log ({ message, o }) {
console.log(message)
if (o) {
console.log(JSON.stringify(o, null, 2))
}
return null
},
})
// let's increase the browser window size when running headlessly
// this will produce higher resolution images and videos
// https://on.cypress.io/browser-launch-api
on('before:browser:launch', (browser = {}, launchOptions) => {
console.log(
'launching browser %s is headless? %s',
browser.name,
browser.isHeadless
)
// the browser width and height we want to get
// our screenshots and videos will be of that resolution
const width = 1920
const height = 1080
console.log('setting the browser window size to %d x %d', width, height)
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push(`--window-size=${width},${height}`)
// force screen to be non-retina and just use our given resolution
launchOptions.args.push('--force-device-scale-factor=1')
}
if (browser.name === 'electron' && browser.isHeadless) {
// might not work on CI for some reason
launchOptions.preferences.width = width
launchOptions.preferences.height = height
}
if (browser.name === 'firefox' && browser.isHeadless) {
launchOptions.args.push(`--width=${width}`)
launchOptions.args.push(`--height=${height}`)
}
return launchOptions
})
},
},
})