2022-10-12 14:21:49 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
const { defineConfig } = require('cypress');
|
2022-12-29 03:55:46 +00:00
|
|
|
const { rm } = require('fs/promises')
|
|
|
|
|
|
|
|
// yes use video compression in CI, where we will set the env var so we upload to cypress dashboard
|
|
|
|
const useVideoCompression = !!process.env.CYPRESS_RECORD_KEY
|
|
|
|
|
|
|
|
// https://github.com/cypress-io/cypress/issues/2522
|
|
|
|
const deleteVideosOnSuccess = (on) => {
|
|
|
|
const filesToDelete = []
|
|
|
|
on('after:spec', (_spec, results) => {
|
|
|
|
if (results.stats.failures === 0 && results.video) {
|
|
|
|
filesToDelete.push(results.video)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
on('after:run', async () => {
|
|
|
|
if (filesToDelete.length) {
|
|
|
|
console.log(
|
|
|
|
'after:run hook: Deleting %d video(s) from successful specs',
|
|
|
|
filesToDelete.length
|
|
|
|
)
|
|
|
|
await Promise.all(filesToDelete.map((videoFile) => rm(videoFile)))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-10-12 14:21:49 +00:00
|
|
|
|
2023-03-05 04:48:23 +00:00
|
|
|
let spiffWorkflowFrontendUrl = `http://localhost:${process.env.SPIFFWORKFLOW_FRONTEND_PORT || 7001}`
|
|
|
|
|
|
|
|
if (process.env.SPIFFWORKFLOW_FRONTEND_URL) {
|
|
|
|
spiffWorkflowFrontendUrl = process.env.SPIFFWORKFLOW_FRONTEND_URL
|
|
|
|
}
|
|
|
|
|
2023-01-09 21:00:02 +00:00
|
|
|
const cypressConfig = {
|
2022-10-12 14:21:49 +00:00
|
|
|
projectId: 'crax1q',
|
2022-12-29 03:55:46 +00:00
|
|
|
|
|
|
|
videoUploadOnPasses: false,
|
2022-10-12 14:21:49 +00:00
|
|
|
chromeWebSecurity: false,
|
|
|
|
e2e: {
|
2023-03-05 04:48:23 +00:00
|
|
|
baseUrl: spiffWorkflowFrontendUrl,
|
2022-12-29 03:55:46 +00:00
|
|
|
setupNodeEvents(on, config) {
|
|
|
|
deleteVideosOnSuccess(on)
|
2022-11-16 03:34:28 +00:00
|
|
|
require('@cypress/grep/src/plugin')(config);
|
|
|
|
return config;
|
2022-10-12 14:21:49 +00:00
|
|
|
},
|
|
|
|
},
|
2022-11-04 16:20:55 +00:00
|
|
|
|
|
|
|
// this scrolls away from the elements for some reason with carbon when set to top
|
|
|
|
// https://github.com/cypress-io/cypress/issues/2353
|
|
|
|
// https://docs.cypress.io/guides/core-concepts/interacting-with-elements#Scrolling
|
|
|
|
scrollBehavior: "center",
|
2023-01-09 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.CYPRESS_RECORD_KEY) {
|
|
|
|
// since it's slow
|
|
|
|
cypressConfig.videoCompression = false
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = defineConfig(cypressConfig)
|