Skip to content

Commit 024c417

Browse files
committed
further integration test and doc improvements
1 parent 3fdf04b commit 024c417

File tree

2 files changed

+29
-13
lines changed
  • packages

2 files changed

+29
-13
lines changed

packages/browser-integration-tests/suites/integrations/ContextLines/test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/types';
32

43
import { sentryTest } from '../../../utils/fixtures';
5-
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers';
4+
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../utils/helpers';
65

76
sentryTest(
87
'should add source context lines around stack frames from errors in Html inline JS',
9-
async ({ getLocalTestPath, page }) => {
8+
async ({ getLocalTestPath, page, browserName }) => {
9+
if (browserName === 'webkit') {
10+
// The error we're throwing in this test is thrown as "Script error." in Webkit.
11+
// We filter "Script error." out by default in `InboundFilters`.
12+
// I don't think there's much value to disable InboundFilters defaults for this test,
13+
// given that most of our users won't do that either.
14+
// Let's skip it instead for Webkit.
15+
sentryTest.skip();
16+
}
17+
1018
const url = await getLocalTestPath({ testDir: __dirname });
1119

12-
const eventPromise = getFirstSentryEnvelopeRequest<Event>(page, url);
20+
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
1321

1422
const clickPromise = page.click('#inline-error-btn');
1523

16-
const [eventData] = await Promise.all([eventPromise, clickPromise]);
24+
const [req] = await Promise.all([eventReqPromise, clickPromise]);
25+
26+
const eventData = envelopeRequestParser(req);
1727

1828
expect(eventData.exception?.values).toHaveLength(1);
1929

@@ -41,11 +51,14 @@ sentryTest(
4151
sentryTest('should not add source context lines to errors from script files', async ({ getLocalTestPath, page }) => {
4252
const url = await getLocalTestPath({ testDir: __dirname });
4353

44-
const eventPromise = getFirstSentryEnvelopeRequest<Event>(page, url);
54+
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
55+
56+
const clickPromise = page.click('#script-error-btn');
57+
58+
const [req] = await Promise.all([eventReqPromise, clickPromise]);
4559

46-
await page.click('#script-error-btn');
60+
const eventData = envelopeRequestParser(req);
4761

48-
const eventData = await eventPromise;
4962
const exception = eventData.exception?.values?.[0];
5063
const frames = exception?.stacktrace?.frames;
5164
expect(frames).toHaveLength(1);

packages/browser/src/integrations/contextlines.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ interface ContextLinesOptions {
1414
}
1515

1616
/**
17-
* Collects source context lines around the line of a stackframe
18-
* This integration only works for stack frames pointing to JS that's directly embedded
19-
* in HTML files.
20-
* It DOES NOT work for stack frames pointing to JS files that are loaded by the browser.
21-
* For frames pointing to files, context lines are added during ingestino and symbolication
17+
* Collects source context lines around the line of a stackframe pointing to JS embedded in
18+
* the current page's HTML.
19+
*
20+
* Use this integration if you have inline JS code in HTML pages that can't be accessed
21+
* by our backend (e.g. due to a login-protected page).
22+
*
23+
* This integratino DOES NOT work for stack frames pointing to JS files that are loaded by the browser.
24+
* For frames pointing to files, context lines are added during ingestion and symbolication
2225
* by attempting to download the JS files to the Sentry backend.
2326
*/
2427
export class ContextLines implements Integration {

0 commit comments

Comments
 (0)