-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
52 lines (45 loc) · 1.66 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
const fs = require('fs')
const path = require('path')
const { defineConfig } = require('cypress')
const env = require('./cypress.env')
const width = 1440
const height = 900
module.exports = defineConfig({
screenshotsFolder: 'output/screenshots',
videosFolder: 'output/videos',
numTestsKeptInMemory: 1,
viewportWidth: width,
viewportHeight: height,
retries: {
openMode: 0,
runMode: 0,
},
e2e: {
setupNodeEvents(on, config) {
on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args = launchOptions.args.filter((arg) => !arg.startsWith('--force-device-scale-factor=') && !arg.startsWith('--window-size='))
launchOptions.args.push('--force-device-scale-factor=2')
launchOptions.args.push(`--window-size=${width},${height + 200}`)
}
return launchOptions
})
on('after:screenshot', (details) => {
const parts = details.path.replace(config.screenshotsFolder, '').split(path.sep)
const a = parts.slice(2)
const newPath = `${config.screenshotsFolder}${path.sep}${a.join(path.sep)}`
const originalDir = `${config.screenshotsFolder}${path.sep}${parts[1]}`
const newDir = newPath.split(path.sep).slice(0, -1).join(path.sep)
return new Promise((resolve, reject) => {
fs.mkdirSync(newDir, { recursive: true })
fs.rename(details.path, newPath, (err) => {
if (err) return reject(err)
fs.rmdirSync(originalDir, { recursive: true })
resolve({ path: newPath })
})
})
})
},
env,
},
})