Skip to content

Commit c23f1d7

Browse files
committed
debug: Capture and print console logs in spotlight test
1 parent df539cf commit c23f1d7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

dev-packages/e2e-tests/test-applications/nextjs-15-spotlight/tests/spotlight.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,39 @@ import { expect, test } from '@playwright/test';
22

33
test.describe('Spotlight auto-enablement in Next.js development mode', () => {
44
test('Spotlight is automatically enabled when NEXT_PUBLIC_SENTRY_SPOTLIGHT=true', async ({ page }) => {
5+
// Capture console logs for debugging
6+
const consoleLogs: string[] = [];
7+
page.on('console', msg => {
8+
const text = msg.text();
9+
consoleLogs.push(`[${msg.type()}] ${text}`);
10+
// Print Sentry debug logs immediately
11+
if (text.includes('[Sentry Debug]') || text.includes('Spotlight')) {
12+
console.log(`BROWSER: ${text}`);
13+
}
14+
});
15+
516
await page.goto('/');
617

718
// Wait for client-side hydration and Sentry initialization
819
await page.waitForTimeout(3000);
920

21+
// Print all console logs for debugging
22+
console.log('=== Browser Console Logs ===');
23+
consoleLogs.forEach(log => console.log(log));
24+
console.log('=== End Console Logs ===');
25+
1026
// Check environment variable is accessible (injected at build time)
1127
const envValue = await page.getByTestId('env-value').textContent();
28+
console.log('env-value content:', envValue);
1229
expect(envValue).toContain('true');
1330

31+
// Check globalThis value (set by valueInjectionLoader)
32+
const globalThisValue = await page.getByTestId('globalthis-value').textContent();
33+
console.log('globalthis-value content:', globalThisValue);
34+
1435
// Check Spotlight integration is enabled
1536
const spotlightStatus = await page.getByTestId('spotlight-enabled').textContent();
37+
console.log('spotlight-enabled content:', spotlightStatus);
1638
expect(spotlightStatus).toBe('ENABLED');
1739
});
1840

0 commit comments

Comments
 (0)