File tree Expand file tree Collapse file tree 5 files changed +45
-0
lines changed
browser-integration-tests/loader-suites/loader/onLoad/keepSentryGlobal Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ window . sentryOnLoad = function ( ) {
2+ Sentry . init ( { } ) ;
3+
4+ window . __sentryLoaded = true ;
5+ }
Original file line number Diff line number Diff line change 1+ Sentry . forceLoad ( ) ;
2+
3+ Sentry . captureException ( 'Test exception' ) ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < script >
6+ window . Sentry = { _customThingOnSentry : 'customThingOnSentry' } ;
7+ </ script >
8+ </ head >
9+ < body > </ body >
10+ </ html >
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+
3+ import { sentryTest } from '../../../../utils/fixtures' ;
4+ import { envelopeRequestParser , waitForErrorRequestOnUrl } from '../../../../utils/helpers' ;
5+
6+ sentryTest ( 'keeps data on window.Sentry intact' , async ( { getLocalTestUrl, page } ) => {
7+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
8+ return route . fulfill ( {
9+ status : 200 ,
10+ contentType : 'application/json' ,
11+ body : JSON . stringify ( { id : 'test-id' } ) ,
12+ } ) ;
13+ } ) ;
14+
15+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
16+ const req = await waitForErrorRequestOnUrl ( page , url ) ;
17+
18+ const eventData = envelopeRequestParser ( req ) ;
19+
20+ expect ( eventData . message ) . toBe ( 'Test exception' ) ;
21+
22+ const customThingy = await page . evaluate ( 'window.Sentry._customThingOnSentry' ) ;
23+ expect ( customThingy ) . toBe ( 'customThingOnSentry' ) ;
24+ } ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ export function makeBaseBundleConfig(options) {
4848 output : {
4949 format : 'iife' ,
5050 name : 'Sentry' ,
51+ intro : ( ) => {
52+ return 'exports = window.Sentry || {};' ;
53+ } ,
5154 } ,
5255 context : 'window' ,
5356 plugins : [ rrwebBuildPlugin , markAsBrowserBuildPlugin ] ,
You can’t perform that action at this time.
0 commit comments