-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcypress.config.ts
More file actions
90 lines (85 loc) · 2.77 KB
/
Copy pathcypress.config.ts
File metadata and controls
90 lines (85 loc) · 2.77 KB
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
85
86
87
88
89
90
import fs from 'node:fs'
import { defineConfig } from 'cypress'
import viteConfig from './vite-cypress.config'
const setupNodeEvents = async (
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
) => {
// Delete videos for passing tests
on('after:spec', (_, results) => {
try {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === 'failed')
)
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video)
}
}
} catch (error) {
if (
typeof error === 'object' &&
error !== null &&
'code' in error &&
error.code === 'ENOENT'
) {
// eslint-disable-next-line no-console
console.log('Video already deleted')
} else {
throw error
}
}
})
if (!config.env.dhis2InstanceVersion) {
throw new Error(
'dhis2InstanceVersion is missing. Check the README for more information.'
)
}
// Bridge non-sensitive env vars to expose so browser code can use
// Cypress.expose() instead of the deprecated Cypress.env()
config.expose = {
...config.expose,
dhis2BaseUrl: config.env.dhis2BaseUrl,
dhis2InstanceVersion: config.env.dhis2InstanceVersion,
dhis2DatatestPrefix: config.env.dhis2DatatestPrefix,
hideRequestsFromLog: config.env.hideRequestsFromLog,
}
return config
}
module.exports = defineConfig({
projectId: 'prcq4z',
e2e: {
setupNodeEvents,
baseUrl: 'http://localhost:3000',
specPattern: 'cypress/e2e/**/*.cy.ts',
viewportWidth: 1280,
viewportHeight: 800,
// Record video
video: true,
// Enabled to reduce the risk of out-of-memory issues
experimentalMemoryManagement: true,
// Set to a low number to reduce the risk of out-of-memory issues
numTestsKeptInMemory: 5,
/* When allowing 1 retry on CI, the test suite will pass if
* it's flaky. And/but we also get to identify flaky tests on the
* Cypress Dashboard. */
retries: {
runMode: 1,
openMode: 0,
},
defaultCommandTimeout: 30000,
},
allowCypressEnv: false,
expose: {
dhis2DatatestPrefix: 'dhis2-eventvisualizer',
},
component: {
devServer: {
framework: 'react',
bundler: 'vite',
viteConfig,
},
},
})