-
Notifications
You must be signed in to change notification settings - Fork 433
/
cypress.config.js
74 lines (66 loc) · 2.1 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
63
64
65
66
67
68
69
70
71
72
73
74
import { defineConfig } from 'cypress'
import 'dotenv/config'
import * as fs from 'fs'
import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
import matter from 'gray-matter'
import { configureVisualRegression } from 'cypress-visual-regression'
const __dirname = dirname(fileURLToPath(import.meta.url))
export default defineConfig({
projectId: 'exhdra',
trashAssetsBeforeRuns: true,
reporter: 'junit',
reporterOptions: {
mochaFile: 'reports/junit-[hash].xml',
},
retries: {
runMode: 3,
openMode: 0,
},
e2e: {
screenshotsFolder: './cypress/snapshots/actual',
setupNodeEvents(on, config) {
// Read and parse the terms Markdown file
try {
const filePath = path.resolve(__dirname, './src/markdown/terms/terms.md')
const content = fs.readFileSync(filePath, 'utf8')
const parsed = matter(content)
const frontmatter = parsed.data
// Set Cookie term version on the cypress env - this way we can access it in the tests
config.env.CURRENT_COOKIE_TERMS_VERSION = frontmatter.version
} catch (error) {
console.error('Error reading or parsing terms.md file:', error)
}
configureVisualRegression(on),
on('task', {
log(message) {
console.log(message)
return null
},
})
on('after:spec', (spec, results) => {
if (results && results.video) {
const failures = results.tests.some((test) => test.attempts.some((attempt) => attempt.state === 'failed'))
if (!failures) {
fs.unlinkSync(results.video)
}
}
})
return config
},
env: {
...process.env,
visualRegressionType: 'regression',
visualRegressionBaseDirectory: 'cypress/snapshots/actual',
visualRegressionDiffDirectory: 'cypress/snapshots/diff',
visualRegressionGenerateDiff: 'fail',
},
baseUrl: 'http://localhost:3000',
testIsolation: false,
hideXHR: true,
defaultCommandTimeout: 10000,
pageLoadTimeout: 60000,
numTestsKeptInMemory: 0,
},
chromeWebSecurity: false,
})