File tree Expand file tree Collapse file tree 4 files changed +59
-1
lines changed
packages/browser-integration-tests
loader-suites/loader/onLoad/customIntegrationsFunction Expand file tree Collapse file tree 4 files changed +59
-1
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+ class CustomIntegration {
6+ constructor ( ) {
7+ this . name = 'CustomIntegration' ;
8+ }
9+
10+ setupOnce ( ) { }
11+ }
12+
13+ Sentry . onLoad ( function ( ) {
14+ Sentry . init ( {
15+ integrations : integrations => [ new CustomIntegration ( ) ] . concat ( integrations ) ,
16+ } ) ;
17+
18+ window . __sentryLoaded = true ;
19+ } ) ;
Original file line number Diff line number Diff line change 1+ Sentry . forceLoad ( ) ;
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+
3+ import { sentryTest } from '../../../../utils/fixtures' ;
4+
5+ sentryTest (
6+ 'should not add default integrations if integrations function is provided' ,
7+ async ( { getLocalTestUrl, page } ) => {
8+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
9+ return route . fulfill ( {
10+ status : 200 ,
11+ contentType : 'application/json' ,
12+ body : JSON . stringify ( { id : 'test-id' } ) ,
13+ } ) ;
14+ } ) ;
15+
16+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
17+ await page . goto ( url ) ;
18+
19+ await page . waitForFunction ( ( ) => {
20+ return ( window as any ) . __sentryLoaded ;
21+ } ) ;
22+
23+ const hasCustomIntegration = await page . evaluate ( ( ) => {
24+ return ! ! ( window as any ) . Sentry . getCurrentHub ( ) . getClient ( ) . getIntegrationById ( 'CustomIntegration' ) ;
25+ } ) ;
26+
27+ const hasReplay = await page . evaluate ( ( ) => {
28+ return ! ! ( window as any ) . Sentry . getCurrentHub ( ) . getClient ( ) . getIntegrationById ( 'Replay' ) ;
29+ } ) ;
30+ const hasBrowserTracing = await page . evaluate ( ( ) => {
31+ return ! ! ( window as any ) . Sentry . getCurrentHub ( ) . getClient ( ) . getIntegrationById ( 'BrowserTracing' ) ;
32+ } ) ;
33+
34+ expect ( hasCustomIntegration ) . toEqual ( true ) ;
35+ expect ( hasReplay ) . toEqual ( false ) ;
36+ expect ( hasBrowserTracing ) . toEqual ( false ) ;
37+ } ,
38+ ) ;
You can’t perform that action at this time.
0 commit comments