forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.mjs
84 lines (80 loc) · 2.58 KB
/
cypress.config.mjs
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
import { defineConfig } from 'cypress'
import { rm } from 'node:fs/promises'
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { initPlugin as initVisualRegressionPlugin } from '@frsource/cypress-plugin-visual-regression-diff/plugins'
import pkg from '../package.json' assert { type: 'json' }
const dir = dirname(fileURLToPath(import.meta.url))
const isCYCI = !process.env.CY_OPEN
const root = resolve(dir, '..')
// we don't need to optimize graphql and apollo
const skipDeps = ['graphql', 'apollo', '@tiptap/pm']
export default defineConfig({
videosFolder: '.cypress/videos',
supportFolder: '.cypress/support/index.js',
fixturesFolder: '.cypress/fixtures',
downloadsFolder: '.cypress/downloads',
screenshotsFolder: '.cypress/screenshots',
videoCompression: false,
env: {
CY_CI: isCYCI,
pluginVisualRegressionDiffConfig: {
threshold: 0.02,
},
pluginVisualRegressionMaxDiffThreshold: 0.02,
},
component: {
supportFile: '.cypress/support/index.js',
setupNodeEvents(on, config) {
on('after:spec', (spec, results) => {
if (results && results.stats.failures === 0 && results.video) {
return rm(results.video)
}
})
initVisualRegressionPlugin(on, config)
on('before:browser:launch', (browser, launchOptions) => {
if (browser?.family === 'chromium' && browser?.name !== 'electron') {
launchOptions.args.push('--force-device-scale-factor=2')
}
return launchOptions
})
},
devServer: {
framework: 'vue',
bundler: 'vite',
viteConfig: {
mode: 'cypress',
root,
configFile: resolve(dir, '..', 'vite.config.mjs'),
cacheDir: resolve(dir, 'node_modules', '.vite'),
server: {
fs: {
strict: false,
},
hmr: true,
...(isCYCI && { watch: { ignored: ['**/*'] } }),
},
optimizeDeps: {
entries: [
'**/cypress/**/*.cy.ts',
'!**/node_modules/**',
'!**/*.d.ts',
],
include: [
// if you see cypress failing on some dependency, add it to skipDeps
...Object.keys(pkg.dependencies).filter(
(name) => !skipDeps.some((dep) => name.includes(dep)),
),
],
},
},
},
// iPhone 12 viewport
viewportWidth: 390,
viewportHeight: 844,
fileServerFolder: '..',
indexHtmlFile: '.cypress/support/component-index.html',
specPattern: ['app/frontend/cypress/**/*.cy.{js,jsx,ts,tsx}'],
},
retries: 0,
})