From d1cc7459c262f9a3b0b062927ed0eeeeebb1e7f1 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 24 Nov 2026 16:00:06 +0100 Subject: [PATCH 1/2] test(e2e): Load the WebView demo's browser SDK asynchronously The WebView demo page loaded @sentry/browser from the CDN with a blocking script in . Until the CDN responded, the page's own script that reads the injected sentry-trace meta tag and posts it back to React Native could not run. On CI emulators with a slow network this outlasted the E2E wait, so the trace status stayed "not connected" and the test failed. Load the CDN script with async and call Sentry.init from its onload. Refs #7093 Co-Authored-By: Claude Opus 5.5 --- .../src/Screens/WebviewScreen.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/samples/react-native/src/Screens/WebviewScreen.tsx b/samples/react-native/src/Screens/WebviewScreen.tsx index f6c119d81b..43fe8403de 100644 --- a/samples/react-native/src/Screens/WebviewScreen.tsx +++ b/samples/react-native/src/Screens/WebviewScreen.tsx @@ -24,21 +24,26 @@ function buildDemoPage(dsn: string): string { - + +

WebView page

From 1a2d20482a29677cf20c6945f5d31749f547e2b0 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 24 Nov 2026 16:53:30 +0100 Subject: [PATCH 2/2] test(e2e): Print the screen texts when the WebView trace test fails The WebView trace test only reported that the "connected" status never appeared. Print the texts on screen, including the WebView page's own text, so a CI failure shows whether the page never saw the injected meta tag, the page script never ran, or the readback did not reach React Native. Refs #7093 Co-Authored-By: Claude Opus 5.5 --- .../webViewTraceConnection.test.ts | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/samples/react-native/e2e/tests/webViewTraceConnection/webViewTraceConnection.test.ts b/samples/react-native/e2e/tests/webViewTraceConnection/webViewTraceConnection.test.ts index b740ee864c..fe508ce7e5 100644 --- a/samples/react-native/e2e/tests/webViewTraceConnection/webViewTraceConnection.test.ts +++ b/samples/react-native/e2e/tests/webViewTraceConnection/webViewTraceConnection.test.ts @@ -1,7 +1,33 @@ -import { describe, it, expect } from '@jest/globals'; +import { describe, it } from '@jest/globals'; +import { execFileSync } from 'node:child_process'; +import path from 'node:path'; import { maestro } from '../../utils/maestro'; +/** + * Prints the texts on screen, including the WebView page's own text, so a failure + * shows how far the trace got: "(none — not injected)" means the page never saw the + * injected meta tag, "(reading…)" means the page script never ran, and a trace value + * in the page means the readback was not delivered to or not matched in React Native. + */ +function printScreenTexts(): void { + try { + const hierarchy = execFileSync('maestro', ['hierarchy'], { + cwd: path.join(__dirname, '../..'), + encoding: 'utf8', + maxBuffer: 64 * 1024 * 1024, + timeout: 120000, + }); + // In screen order: the React Native panel first, then the WebView page. + const texts = [...hierarchy.matchAll(/"(?:text|accessibilityText|hintText)"\s*:\s*"([^"]+)"/g)].map( + match => match[1], + ); + console.log('Screen texts after the WebView flow failed:\n' + texts.join('\n')); + } catch (e) { + console.log('Could not read the screen hierarchy:', e); + } +} + describe('WebView trace connection', () => { it('injects the React Native trace into the WebView, which reads it back', async () => { // The check runs on-device in the Maestro flow: it opens the WebView demo @@ -9,8 +35,11 @@ describe('WebView trace connection', () => { // which only happens when the page reads back the injected `sentry-trace` // meta tag and it matches the trace active in React Native. A failed // injection makes the flow exit non-zero, rejecting this promise. - await expect( - maestro('tests/webViewTraceConnection/webViewTraceConnection.test.yml'), - ).resolves.toBeUndefined(); + try { + await maestro('tests/webViewTraceConnection/webViewTraceConnection.test.yml'); + } catch (error) { + printScreenTexts(); + throw error; + } }, 240000); });