Skip to content

test: retry flaky system tests#33477

Open
mschile wants to merge 2 commits intodevelopfrom
mschile/retry_system_tests
Open

test: retry flaky system tests#33477
mschile wants to merge 2 commits intodevelopfrom
mschile/retry_system_tests

Conversation

@mschile
Copy link
Contributor

@mschile mschile commented Mar 14, 2026

  • Closes N/A (no linked issue)

Additional details

  • Adds optional retries support to the system test runner (ItOptions and localItFn default options) so individual tests can be retried on failure.
  • Applies retries to known flaky system tests: downloads (5 retries), service worker / protocol (10 retries), and Vite dev server fresh (10 retries).

Note

Low Risk
Low risk: changes are confined to the system test harness and a handful of system specs, only affecting CI test retry behavior.

Overview
Adds optional retries support to systemTests.it (ItOptions) and applies it via Mocha’s this.retries() when generating per-browser tests.

Updates several known-flaky system tests to run with retries (e.g. downloads, service worker/protocol, Vite dev server fresh), and resets service-worker request counters within the retried onRun hook to avoid cross-attempt state leakage.

Written by Cursor Bugbot for commit 420aabb. This will update automatically on new commits. Configure here.

Steps to test

  • Run the affected system tests (e.g. yarn test-system scoped to downloads, service worker, or vite dev server specs) and confirm they run with retries on failure where configured.

How has the user experience changed?

  • No user-facing change. CI/system test stability only.

PR Tasks

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Options-based retries never applied to Mocha tests
    • systemTests.it() now applies the configured retry count by calling this.retries(options.retries) inside the generated Mocha test callback.
  • ✅ Fixed: Accumulated counter makes retries always fail after first attempt
    • The service worker request counter is reset at the start of onRun, so each retry attempt validates against a fresh counter value.

Create PR

Or push these changes by commenting:

@cursor push 364f2ac9c7
Preview (364f2ac9c7)
diff --git a/system-tests/lib/system-tests.ts b/system-tests/lib/system-tests.ts
--- a/system-tests/lib/system-tests.ts
+++ b/system-tests/lib/system-tests.ts
@@ -537,6 +537,8 @@
     const testTitle = `${title} [${browser}]`
 
     return mochaItFn(testTitle, function () {
+      this.retries(options.retries)
+
       if (options.useSeparateBrowserSnapshots) {
         title = testTitle
       }

diff --git a/system-tests/test/service_worker_spec.js b/system-tests/test/service_worker_spec.js
--- a/system-tests/test/service_worker_spec.js
+++ b/system-tests/test/service_worker_spec.js
@@ -49,6 +49,7 @@
     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

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@cypress
Copy link

cypress bot commented Mar 14, 2026

cypress    Run #69372

Run Properties:  status check passed Passed #69372  •  git commit 420aabb05e: updates
Project cypress
Branch Review mschile/retry_system_tests
Run status status check passed Passed #69372
Run duration 18m 33s
Commit git commit 420aabb05e: updates
Committer Matthew Schile
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 11
Tests that did not run due to a developer annotating a test with .skip  Pending 1112
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 27193
View all changes introduced in this branch ↗︎
UI Coverage  61.84%
  Untested elements 27  
  Tested elements 47  
Accessibility  98.98%
  Failed rules  0 critical   3 serious   1 moderate   0 minor
  Failed elements 19  

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

const testTitle = `${title} [${browser}]`

return mochaItFn(testTitle, function () {
this.retries(options.retries)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default retries overrides suite-level Mocha retry inheritance

Low Severity

The retries: 0 default in DEFAULT_OPTIONS causes this.retries(0) to be called unconditionally for every systemTests.it() test. In Mocha, explicitly calling this.retries(0) is semantically different from never calling this.retries() — the former prevents the test from inheriting retry settings from a parent suite, while the latter allows inheritance. This means all systemTests.it() tests now silently override any suite-level retry configuration. The call to this.retries() would be better guarded with a condition like checking if options.retries was explicitly provided.

Fix in Cursor Fix in Web

Triggered by project rule: Overview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant