diff --git a/system-tests/lib/system-tests.ts b/system-tests/lib/system-tests.ts index 6391f05b68..cddb6b5c14 100644 --- a/system-tests/lib/system-tests.ts +++ b/system-tests/lib/system-tests.ts @@ -68,6 +68,10 @@ export type ItOptions = ExecOptions & { * Same as using `systemTests.it.skip`. */ skip?: boolean + /** + * If set, the system test will be retried up to the given number of times. + */ + retries?: number } type ExecOptions = { @@ -532,6 +536,11 @@ const localItFn = function (title: string, opts: ItOptions) { const testTitle = `${title} [${browser}]` return mochaItFn(testTitle, function () { + // Only set retries when explicitly provided; otherwise allow Mocha to inherit from parent suite + if ('retries' in opts) { + this.retries(options.retries) + } + if (options.useSeparateBrowserSnapshots) { title = testTitle } diff --git a/system-tests/test/downloads_spec.ts b/system-tests/test/downloads_spec.ts index 84234a689f..5f88353147 100644 --- a/system-tests/test/downloads_spec.ts +++ b/system-tests/test/downloads_spec.ts @@ -60,6 +60,8 @@ describe('e2e downloads', () => { }) it('does not trash downloads between runs if trashAssetsBeforeRuns: false', async function () { + this.retries(10) + await systemTests.exec(this, { project: 'downloads', spec: 'download_csv.cy.ts', diff --git a/system-tests/test/service_worker_protocol_spec.js b/system-tests/test/service_worker_protocol_spec.js index f67d86b426..c6180b29de 100644 --- a/system-tests/test/service_worker_protocol_spec.js +++ b/system-tests/test/service_worker_protocol_spec.js @@ -27,6 +27,8 @@ describe('capture-protocol', () => { describe('service worker', () => { BROWSERS.forEach((browser) => { it(`verifies the types of requests match - ${browser}`, function () { + this.retries(10) + return systemTests.exec(this, { key: 'f858a2bc-b469-4e48-be67-0876339ee7e1', project: 'protocol', diff --git a/system-tests/test/service_worker_spec.js b/system-tests/test/service_worker_spec.js index 6452e1c55b..7e56936560 100644 --- a/system-tests/test/service_worker_spec.js +++ b/system-tests/test/service_worker_spec.js @@ -47,7 +47,9 @@ describe('e2e service worker', () => { systemTests.it('executes one spec with a cached call', { project: 'e2e', spec: 'service_worker.cy.js', + retries: 10, onRun: async (exec, browser) => { + requestsForServiceWorkerCache = 0 await exec() // Ensure that we only called this once even though we loaded the // service worker twice diff --git a/system-tests/test/vite_dev_server_fresh_spec.ts b/system-tests/test/vite_dev_server_fresh_spec.ts index 9ca3263dfc..bd08412fca 100644 --- a/system-tests/test/vite_dev_server_fresh_spec.ts +++ b/system-tests/test/vite_dev_server_fresh_spec.ts @@ -13,6 +13,8 @@ describe('@cypress/vite-dev-server', function () { describe('react', () => { for (const project of VITE_REACT) { it(`executes all of the specs for ${project}`, function () { + this.retries(10) + return systemTests.exec(this, { project, configFile: 'cypress-vite.config.ts',