Skip to content

test(e2e): Fix flaky sample app E2E tests - #7097

Merged
antonis merged 2 commits into
mainfrom
test/sample-e2e-flakes
Nov 24, 2026
Merged

antonis merged 2 commits into
mainfrom
test/sample-e2e-flakes

Conversation

@antonis

@antonis antonis commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Fixes two causes of flaky sample app E2E tests in sample-application.yml and adds a diagnostic for a third.

Leaked envelopes between test files (Android and iOS). Each test file starts its own mocked Sentry server, but the app launched by the previous test file keeps running until the next Maestro flow relaunches it. Maestro's startup takes about 10 s, and transactions the old app finishes in that window (idle navigation spans end 5 s after the last activity) are delivered to the new test's server. createSentryServer().start() now stops the app first (adb shell am force-stop on Android, xcrun simctl terminate booted on iOS). The platform comes from a new E2E_PLATFORM Jest global in the four platform configs.

device.connection_type on the iOS message event. sentry-cocoa only sets it after SentryReachability reported the first network path, which happens asynchronously after start. The iOS auto flow captures the message right after launch, so it can be sent without the field. The message test now only checks the type when the field is present. A new contains device connection type test asserts it on the ErrorsScreen transaction, which is sent about 5 s after launch, on both platforms.

Diagnostic for the Android ErrorsScreen app start failure. When no ErrorsScreen transaction with origin auto.app.start arrived, the test now prints every received transaction (name, op, origin, timestamps, measurement keys, span ops) before failing. The root cause of this failure is not found yet: it did not reproduce locally.

💡 Motivation and Context

Refs #7093. 21 of 38 main runs had a first-attempt failure in the sample E2E jobs.

  • The 4 iOS captureMessage "contains device context" failures I checked all lacked only connection_type. The assertion was added in feat(core): Report cellular network technology #6827.
  • The leak was caught locally: a Webview transaction from the previous test's app reached the Spaceflight test's server about 8 s after it started, and failed "all navigation transaction envelopes have time to display measurements". This matches one iOS CI failure. It is also a candidate for the Android ErrorsScreen failure, which always runs right after the Spaceflight test.

Not addressed here:

  • The Android WebView trace test timing out (7 failures). It did not reproduce locally.
  • Maestro UI timeouts (No visible element found, Load More Articles).
  • The TAR_BAD_ARCHIVE dependency install failure.

💚 How did you test it?

Locally, with the sample-rn-new-production-android APK from a recent main run, on an emulator matching CI (API 30 aosp_atd, -gpu swiftshader_indirect, 2 cores, arm64 instead of CI's x86_64):

  • Before the change: 1 of 3 full-suite runs failed (the leaked Webview transaction above, plus a TurboModule UI timeout).
  • After the change: 5 of 5 full-suite runs passed (25/25 tests), including the new connection_type test. The logcat shows the force-stop before each test file.

The iOS changes were not run locally; CI ran them.

CI on this PR: every completed sample E2E job passed, with no failed tests:

Run Attempt Android (25 tests) iOS (21 tests)
45389105423 (2853575) 1 ✅ ✅
45396779589 (merge of main) 1 ✅ ✅
45396779589, job rerun 4 ✅
45396779589, job rerun 5 ✅
45396779589, job rerun 6 ✅
45396779589, job rerun 7 ✅
45396779589, job rerun 8 ✅
  • Android 5/5 and iOS 4/4 passed, including the new contains device connection type test on both platforms. On main, Android failed on the first attempt in 15 of 38 runs and iOS in 6 of 38.
  • Three earlier job reruns were cancelled before they finished and are not counted. I ran them on two runs of this PR at the same time, and the workflow's per-ref concurrency group cancelled each in favour of the other. The reruns above ran one at a time.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

  • Run the sample E2E jobs several times on this PR and compare the first-attempt failure rate with main.
  • If the Android ErrorsScreen test fails again, use the printed transactions to find the cause.
  • Investigate the Android WebView trace test separately.

🤖 Generated with Claude Code

Stop the sample app before each test file starts its mocked Sentry
server. The app launched by the previous test file kept running until
the next Maestro flow relaunched it, so transactions it finished in the
meantime were delivered to the next test's server and mixed into its
envelopes.

Make device.connection_type optional on the iOS message event. sentry-cocoa
only knows it after its reachability monitor reported the first network
path, which can be after a message captured right after launch. Assert it
on the ErrorsScreen transaction instead, which is sent seconds later.

Print the received transactions when the ErrorsScreen app start
transaction is missing, to diagnose the remaining Android failure.

Refs #7093

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • test(e2e): Fix flaky sample app E2E tests by antonis and claude in #7097
  • ci(ios): Build the SwiftPM app on more React Native versions by alwx in #7096
  • chore(tooling): Remove Cursor Bugbot review guidelines by antonis and claude in #7090
  • fix(core): Capture uncaught render errors on React Native 0.78+ by alwx in #7078
  • ci: Fix stale high_risk_code paths in file-filters by antonis and claude in #7091
  • ci(e2e): Fix legacy Android e2e jobs building New Architecture by antonis and claude in #7092
  • chore(deps): update Android SDK to v8.65.1 by github-actions in #7089
  • fix(core): Remove native scope tags set to an empty value by antonis and claude in #7087
  • feat(ios): Add metricKitHangReportingMode option for MetricKit hang flame graphs by alwx in #7059
  • chore(deps): bump getsentry/craft from 3.12.0 to 3.13.0 by dependabot in #7083
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 3.12.0 to 3.13.0 by dependabot in #7082
  • chore(deps): bump getsentry/github-workflows/danger from 6bf4a27612e388f9c113d64f75e25190e814b414 to bce11fe6eaa86dbb9d360ab45a96e659828877f0 by dependabot in #7081
  • chore(deps): bump actions/create-github-app-token from 3.3.0 to 3.4.0 by dependabot in #7085
  • chore(deps): bump ruby/setup-ruby from 1.338.0 to 1.342.0 by dependabot in #7084
  • chore(sample): Remove unused Detox setup from the React Native sample by antonis and claude in #7072
  • ci(ios): Build TestFlight sample with Xcode 27 by philprime with sentry-junior in #7065
  • perf(android): Create SDK view managers on demand by alwx in #7049
  • fix(core): Remove web Replay and Feedback from native bundles by default by huextrat, claude and antonis in #7062
  • fix(core): Define UnsafeObject locally instead of deep importing it by alwx in #7061
  • chore(deps): update Android SDK to v8.65.0 by github-actions in #7058

🤖 This preview updates automatically when you update the PR.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Nov 24, 2026
@antonis
antonis marked this pull request as ready for review November 24, 2026 11:58
@sentry

sentry Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.36.0 (116) Release

⚙️ sentry-react-native Build Distribution Settings

@lucas-zimerman lucas-zimerman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM !

@antonis
antonis merged commit a557438 into main Nov 24, 2026
188 of 190 checks passed
@antonis
antonis deleted the test/sample-e2e-flakes branch November 24, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants