2023-03-27 09:48:02 -07:00
|
|
|
import codeCoverageTask from '@cypress/code-coverage/task'
|
2022-06-13 17:43:58 -04:00
|
|
|
import { defineConfig } from 'cypress'
|
2023-04-19 10:50:25 -07:00
|
|
|
import { setupHardhatEvents } from 'cypress-hardhat'
|
2023-05-22 09:02:54 -07:00
|
|
|
import { unlinkSync } from 'fs'
|
2022-06-13 17:43:58 -04:00
|
|
|
|
|
|
|
export default defineConfig({
|
2022-06-16 10:08:25 -04:00
|
|
|
projectId: 'yp82ef',
|
2022-12-15 09:29:47 -05:00
|
|
|
defaultCommandTimeout: 24000, // 2x average block time
|
2022-06-13 17:43:58 -04:00
|
|
|
chromeWebSecurity: false,
|
2023-05-22 09:02:54 -07:00
|
|
|
experimentalMemoryManagement: true, // better memory management, see https://github.com/cypress-io/cypress/pull/25462
|
2023-04-06 09:30:07 -07:00
|
|
|
retries: { runMode: 2 },
|
2022-06-13 17:43:58 -04:00
|
|
|
e2e: {
|
2023-04-19 10:50:25 -07:00
|
|
|
async setupNodeEvents(on, config) {
|
|
|
|
await setupHardhatEvents(on, config)
|
2023-03-27 09:48:02 -07:00
|
|
|
codeCoverageTask(on, config)
|
2023-05-22 09:02:54 -07: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 15:40:52 -04: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-13 17:43:58 -04:00
|
|
|
baseUrl: 'http://localhost:3000',
|
|
|
|
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
|
|
|
|
},
|
|
|
|
})
|