File tree Expand file tree Collapse file tree 8 files changed +99
-56
lines changed
dev-packages/browser-integration-tests/suites/public-api
packages/browser/test/integration/suites Expand file tree Collapse file tree 8 files changed +99
-56
lines changed Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/browser' ;
2+
3+ window . Sentry = Sentry ;
4+
5+ window . _errorCount = 0 ;
6+
7+ Sentry . init ( {
8+ dsn :
'https://[email protected] /1337' , 9+ denyUrls : [ 'foo.js' ] ,
10+ beforeSend : event => {
11+ window . _errorCount ++ ;
12+ return event ;
13+ } ,
14+ } ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * We always filter on the caller, not the cause of the error
3+ *
4+ * > foo.js file called a function in bar.js
5+ * > bar.js file called a function in baz.js
6+ * > baz.js threw an error
7+ *
8+ * foo.js is denied in the `init` call (init.js), thus we filter it
9+ * */
10+ var urlWithDeniedUrl = new Error ( 'filter' ) ;
11+ urlWithDeniedUrl . stack =
12+ 'Error: bar\n' +
13+ ' at http://localhost:5000/foo.js:7:19\n' +
14+ ' at bar(http://localhost:5000/bar.js:2:3)\n' +
15+ ' at baz(http://localhost:5000/baz.js:2:9)\n' ;
16+
17+ /**
18+ * > foo-pass.js file called a function in bar-pass.js
19+ * > bar-pass.js file called a function in baz-pass.js
20+ * > baz-pass.js threw an error
21+ *
22+ * foo-pass.js is *not* denied in the `init` call (init.js), thus we don't filter it
23+ * */
24+ var urlWithoutDeniedUrl = new Error ( 'pass' ) ;
25+ urlWithoutDeniedUrl . stack =
26+ 'Error: bar\n' +
27+ ' at http://localhost:5000/foo-pass.js:7:19\n' +
28+ ' at bar(http://localhost:5000/bar-pass.js:2:3)\n' +
29+ ' at baz(http://localhost:5000/baz-pass.js:2:9)\n' ;
30+
31+ Sentry . captureException ( urlWithDeniedUrl ) ;
32+ Sentry . captureException ( urlWithoutDeniedUrl ) ;
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+ import type { Event } from '@sentry/types' ;
3+
4+ import { sentryTest } from '../../../utils/fixtures' ;
5+ import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers' ;
6+
7+ sentryTest ( 'should allow to ignore specific urls' , async ( { getLocalTestPath, page } ) => {
8+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
9+
10+ const eventData = await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
11+
12+ expect ( eventData . exception ?. values ?. [ 0 ] . type ) . toEqual ( 'Error' ) ;
13+ expect ( eventData . exception ?. values ?. [ 0 ] . value ) . toEqual ( 'pass' ) ;
14+
15+ const count = await page . evaluate ( 'window._errorCount' ) ;
16+ expect ( count ) . toEqual ( 1 ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/browser' ;
2+
3+ window . Sentry = Sentry ;
4+
5+ window . _errorCount = 0 ;
6+
7+ Sentry . init ( {
8+ dsn :
'https://[email protected] /1337' , 9+ ignoreErrors : [ 'ignoreErrorTest' ] ,
10+ beforeSend : event => {
11+ window . _errorCount ++ ;
12+ return event ;
13+ } ,
14+ } ) ;
Original file line number Diff line number Diff line change 1+ Sentry . captureException ( new Error ( 'foo' ) ) ;
2+ Sentry . captureException ( new Error ( 'ignoreErrorTest' ) ) ;
3+ Sentry . captureException ( new Error ( 'bar' ) ) ;
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+ import type { Event } from '@sentry/types' ;
3+
4+ import { sentryTest } from '../../../utils/fixtures' ;
5+ import { getMultipleSentryEnvelopeRequests } from '../../../utils/helpers' ;
6+
7+ sentryTest ( 'should allow to ignore specific errors' , async ( { getLocalTestPath, page } ) => {
8+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
9+
10+ const events = await getMultipleSentryEnvelopeRequests < Event > ( page , 2 , { url } ) ;
11+
12+ expect ( events [ 0 ] . exception ?. values ?. [ 0 ] . type ) . toEqual ( 'Error' ) ;
13+ expect ( events [ 0 ] . exception ?. values ?. [ 0 ] . value ) . toEqual ( 'foo' ) ;
14+ expect ( events [ 1 ] . exception ?. values ?. [ 0 ] . type ) . toEqual ( 'Error' ) ;
15+ expect ( events [ 1 ] . exception ?. values ?. [ 0 ] . value ) . toEqual ( 'bar' ) ;
16+
17+ const count = await page . evaluate ( 'window._errorCount' ) ;
18+ expect ( count ) . toEqual ( 2 ) ;
19+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ function runVariant(variant) {
2222 /**
2323 * The test runner will replace each of these placeholders with the contents of the corresponding file.
2424 */
25- { { suites / config . js } } // biome-ignore format: No trailing commas
2625 { { suites / onerror . js } } // biome-ignore format: No trailing commas
2726 { { suites / onunhandledrejection . js } } // biome-ignore format: No trailing commas
2827 { { suites / builtins . js } } // biome-ignore format: No trailing commas
You can’t perform that action at this time.
0 commit comments