1
- import { JSDOM } from 'jsdom' ;
2
1
import { Transaction } from '../../../src' ;
3
2
import type { ResourceEntry } from '../../../src/browser/metrics' ;
4
3
import { _addMeasureSpans , _addResourceSpans } from '../../../src/browser/metrics' ;
@@ -17,17 +16,9 @@ const mockWindowLocation = {
17
16
hash : '' ,
18
17
} as Window [ 'location' ] ;
19
18
20
- const originalWindowLocation = WINDOW . location ;
21
- // @ts -expect-error store a reference so we can reset it later
22
- const globalDocument = global . document ;
23
- // @ts -expect-error store a reference so we can reset it later
24
- const globalWindow = global . window ;
25
19
// @ts -expect-error store a reference so we can reset it later
26
20
const globalLocation = global . location ;
27
21
28
- console . log ( '\n\n WINDOW!! \n\n' ) ;
29
- console . log ( WINDOW . location ) ;
30
- console . log ( '\n\n' ) ;
31
22
const resourceEntryName = 'https://example.com/assets/to/css' ;
32
23
33
24
describe ( '_addMeasureSpans' , ( ) => {
@@ -272,24 +263,15 @@ describe('_addResourceSpans', () => {
272
263
} ) ;
273
264
274
265
const setGlobalLocation = ( location : Location ) => {
275
- const dom = new JSDOM ( ) ;
276
- // @ts -expect-error need to override global document
277
- global . document = dom . window . document ;
278
- // @ts -expect-error need to override global document
279
- global . window = dom . window ;
280
266
// @ts -expect-error need to override global document
281
- global . location = dom . window . location ;
267
+ global . location = mockWindowLocation ;
282
268
283
- WINDOW . location = location ;
269
+ console . log ( '\n\n WINDOW origin!! \n\n' ) ;
270
+ console . log ( WINDOW . location . origin ) ;
271
+ console . log ( '\n\n' ) ;
284
272
}
285
273
286
274
const resetGlobalLocation = ( ) => {
287
- // @ts -expect-error need to override global document
288
- global . document = globalDocument ;
289
- // @ts -expect-error need to override global document
290
- global . window = globalWindow ;
291
275
// @ts -expect-error need to override global document
292
276
global . location = globalLocation ;
293
-
294
- WINDOW . location = originalWindowLocation ;
295
277
}
0 commit comments