2023-03-27 19:48:02 +03:00
|
|
|
import codeCoverageTask from '@cypress/code-coverage/task'
|
2022-06-14 00:43:58 +03:00
|
|
|
import { defineConfig } from 'cypress'
|
2023-04-19 20:50:25 +03:00
|
|
|
import { setupHardhatEvents } from 'cypress-hardhat'
|
2023-05-22 19:02:54 +03:00
|
|
|
import { unlinkSync } from 'fs'
|
2022-06-14 00:43:58 +03:00
|
|
|
|
|
|
|
export default defineConfig({
|
2022-06-16 17:08:25 +03:00
|
|
|
projectId: 'yp82ef',
|
2022-12-15 17:29:47 +03:00
|
|
|
defaultCommandTimeout: 24000, // 2x average block time
|
2022-06-14 00:43:58 +03:00
|
|
|
chromeWebSecurity: false,
|
2023-05-22 19:02:54 +03:00
|
|
|
experimentalMemoryManagement: true, // better memory management, see https://github.com/cypress-io/cypress/pull/25462
|
2023-04-06 19:30:07 +03:00
|
|
|
retries: { runMode: 2 },
|
2023-06-07 19:29:23 +03:00
|
|
|
videoCompression: false,
|
2022-06-14 00:43:58 +03:00
|
|
|
e2e: {
|
2023-04-19 20:50:25 +03:00
|
|
|
async setupNodeEvents(on, config) {
|
|
|
|
await setupHardhatEvents(on, config)
|
2023-03-27 19:48:02 +03:00
|
|
|
codeCoverageTask(on, config)
|
2023-05-22 19:02:54 +03:00
|
|
|
|
|
|
|
// Delete recorded videos for specs that passed without flakes.
|
|
|
|
on('after:spec', async (spec, results) => {
|
|
|
|
if (results && results.video) {
|
|
|
|
// If there were no failures (including flakes), delete the recorded video.
|
|
|
|
if (!results.tests?.some((test) => test.attempts.some((attempt) => attempt?.state === 'failed'))) {
|
|
|
|
unlinkSync(results.video)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-06-14 22:40:52 +03:00
|
|
|
return {
|
|
|
|
...config,
|
|
|
|
// Only enable Chrome.
|
|
|
|
// Electron (the default) has issues injecting window.ethereum before pageload, so it is not viable.
|
|
|
|
browsers: config.browsers.filter(({ name }) => name === 'chrome'),
|
|
|
|
}
|
|
|
|
},
|
2022-06-14 00:43:58 +03:00
|
|
|
baseUrl: 'http://localhost:3000',
|
|
|
|
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
|
|
|
|
},
|
|
|
|
})
|