Skip to content

Commit 5a19725

Browse files
committed
debug(e2e): Add debug logging to browser-spotlight test
1 parent 8d0301d commit 5a19725

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

dev-packages/e2e-tests/test-applications/browser-spotlight/src/main.jsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11
import * as Sentry from '@sentry/react';
22

3+
// Log debug info about the Spotlight env var and SDK state
4+
console.log('[E2E Debug] VITE_SENTRY_SPOTLIGHT:', import.meta.env.VITE_SENTRY_SPOTLIGHT);
5+
console.log('[E2E Debug] VITE_E2E_TEST_DSN:', import.meta.env.VITE_E2E_TEST_DSN);
6+
37
// Initialize Sentry - the @sentry/react SDK automatically parses
48
// VITE_SENTRY_SPOTLIGHT from import.meta.env (zero-config for Vite!)
59
// This tests the automatic SDK initialization feature.
6-
Sentry.init({
10+
const client = Sentry.init({
711
dsn: import.meta.env.VITE_E2E_TEST_DSN,
812
integrations: [Sentry.browserTracingIntegration()],
913
tracesSampleRate: 1.0,
1014
release: 'e2e-test',
1115
environment: 'qa',
1216
// Use tunnel to capture events at our proxy server
1317
tunnel: 'http://localhost:3031',
18+
debug: true,
1419
// NOTE: We intentionally do NOT set `spotlight` here!
1520
// The SDK should automatically parse VITE_SENTRY_SPOTLIGHT env var
1621
// and enable Spotlight with the URL from the env var
1722
});
1823

19-
function App() {
20-
const handleClick = () => {
21-
throw new Error('Spotlight test error!');
22-
};
23-
24-
return (
25-
<div>
26-
<h1>Spotlight E2E Test</h1>
27-
<p>This page tests that VITE_SENTRY_SPOTLIGHT env var enables Spotlight integration.</p>
28-
<button id="exception-button" onClick={handleClick}>
29-
Trigger Error
30-
</button>
31-
</div>
32-
);
33-
}
24+
// Debug: Check if Spotlight integration was added
25+
console.log('[E2E Debug] Sentry client:', client);
26+
console.log('[E2E Debug] Integrations:', client?.getIntegrations?.());
27+
const spotlightIntegration = client?.getIntegration?.('Spotlight');
28+
console.log('[E2E Debug] Spotlight integration:', spotlightIntegration);
3429

3530
// Simple render without React DOM to keep dependencies minimal
3631
document.getElementById('root').innerHTML = `

dev-packages/e2e-tests/test-applications/browser-spotlight/tests/spotlight.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { waitForError, waitForSpotlightError, waitForSpotlightTransaction } from
1616
* - A regular event proxy server runs on port 3031 to capture tunnel events
1717
*/
1818
test('VITE_SENTRY_SPOTLIGHT env var enables Spotlight and events are sent to sidecar', async ({ page }) => {
19+
// Capture console logs for debugging
20+
page.on('console', msg => {
21+
console.log(`[Browser Console] ${msg.type()}: ${msg.text()}`);
22+
});
23+
1924
// Wait for the error to arrive at the regular tunnel (port 3031)
2025
const tunnelErrorPromise = waitForError('browser-spotlight', event => {
2126
return !event.type && event.exception?.values?.[0]?.value === 'Spotlight test error!';
@@ -51,6 +56,11 @@ test('VITE_SENTRY_SPOTLIGHT env var enables Spotlight and events are sent to sid
5156
* Test that Spotlight receives transaction events as well.
5257
*/
5358
test('VITE_SENTRY_SPOTLIGHT sends transactions to sidecar', async ({ page }) => {
59+
// Capture console logs for debugging
60+
page.on('console', msg => {
61+
console.log(`[Browser Console] ${msg.type()}: ${msg.text()}`);
62+
});
63+
5464
// Wait for a pageload transaction to arrive at the Spotlight sidecar
5565
const spotlightTransactionPromise = waitForSpotlightTransaction('browser-spotlight-sidecar', event => {
5666
return event.type === 'transaction' && event.contexts?.trace?.op === 'pageload';

0 commit comments

Comments
 (0)