generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.ts
79 lines (71 loc) · 2.64 KB
/
cypress.config.ts
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
import { defineConfig } from 'cypress'
import cypressMochawesomeReportPlugin from 'cypress-mochawesome-reporter/plugin'
import fs from 'fs'
import auth from './integration_tests/mockApis/auth'
import courses from './integration_tests/mockApis/courses'
import courseParticipations from './integration_tests/mockApis/courseParticipations'
import manageUsers from './integration_tests/mockApis/manageUsers'
import oasys from './integration_tests/mockApis/oasys'
import prisonApi from './integration_tests/mockApis/prison'
import prisonRegisterApi from './integration_tests/mockApis/prisonRegister'
import person from './integration_tests/mockApis/person'
import referenceData from './integration_tests/mockApis/referenceData'
import referrals from './integration_tests/mockApis/referrals'
import tokenVerification from './integration_tests/mockApis/tokenVerification'
import { resetStubs } from './wiremock'
export const defaultConfig: Cypress.ConfigOptions = {
chromeWebSecurity: false,
fixturesFolder: 'integration_tests/fixtures',
downloadsFolder: 'test_results/integration/downloads',
screenshotsFolder: 'test_results/integration/screenshots',
videosFolder: 'test_results/integration/videos',
reporter: 'cypress-multi-reporters',
reporterOptions: {
configFile: 'integration_tests/reporterConfig.json',
},
video: true,
videoCompression: true,
taskTimeout: 60000,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on) {
cypressMochawesomeReportPlugin(on)
on('task', {
reset: resetStubs,
...auth,
...courses,
...courseParticipations,
...manageUsers,
...oasys,
...person,
...prisonApi,
...prisonRegisterApi,
...referenceData,
...referrals,
...tokenVerification,
log(message) {
console.log(message)
return null
},
table(tableData) {
console.table(tableData)
return null
},
})
on('after:spec', (_spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
if (results?.video && results?.tests) {
const hasFailures = results.tests.some(test => test.attempts.some(attempt => attempt.state === 'failed'))
if (!hasFailures) {
fs.unlinkSync(results.video)
}
}
})
},
baseUrl: 'http://localhost:3007',
excludeSpecPattern: '**/!(*.cy).ts',
specPattern: 'integration_tests/e2e/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'integration_tests/support/index.ts',
},
}
export default defineConfig(defaultConfig)