Skip to content

Commit 12e274e

Browse files
committed
add tests
unflake skip test for bundles un-flake
1 parent 10d17c6 commit 12e274e

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
</head>
6+
<body>
7+
<script></script>
8+
<button onclick="console.log('Test log', document.body)" data-log>Log button</button>
9+
</body>
10+
</html>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../utils/fixtures';
4+
import { getCustomRecordingEvents, shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers';
5+
6+
sentryTest('should capture console messages in replay', async ({ getLocalTestPath, page, forceFlushReplay }) => {
7+
// console integration is not used in bundles/loader
8+
const bundle = process.env.PW_BUNDLE || '';
9+
if (shouldSkipReplayTest() || bundle.startsWith('bundle_') || bundle.startsWith('loader_')) {
10+
sentryTest.skip();
11+
}
12+
13+
const reqPromise0 = waitForReplayRequest(page, 0);
14+
const reqPromise1 = waitForReplayRequest(page, (_event, res) => {
15+
const { breadcrumbs } = getCustomRecordingEvents(res);
16+
17+
return breadcrumbs.filter(breadcrumb => breadcrumb.category === 'console').length > 0;
18+
});
19+
20+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
21+
return route.fulfill({
22+
status: 200,
23+
contentType: 'application/json',
24+
body: JSON.stringify({ id: 'test-id' }),
25+
});
26+
});
27+
28+
const url = await getLocalTestPath({ testDir: __dirname });
29+
30+
await page.goto(url);
31+
await reqPromise0;
32+
33+
await page.click('[data-log]');
34+
35+
await forceFlushReplay();
36+
37+
const { breadcrumbs } = getCustomRecordingEvents(await reqPromise1);
38+
39+
expect(breadcrumbs.filter(breadcrumb => breadcrumb.category === 'console')).toEqual([
40+
{
41+
timestamp: expect.any(Number),
42+
type: 'default',
43+
category: 'console',
44+
data: { arguments: ['Test log', '[HTMLElement: HTMLBodyElement]'], logger: 'console' },
45+
level: 'log',
46+
message: 'Test log [object HTMLBodyElement]',
47+
},
48+
]);
49+
});

0 commit comments

Comments
 (0)