Skip to content

Commit 2bc3a4f

Browse files
committed
set global
1 parent 89373d6 commit 2bc3a4f

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

packages/tracing-internal/test/browser/metrics/index.test.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { JSDOM } from 'jsdom';
21
import { Transaction } from '../../../src';
32
import type { ResourceEntry } from '../../../src/browser/metrics';
43
import { _addMeasureSpans, _addResourceSpans } from '../../../src/browser/metrics';
@@ -17,17 +16,9 @@ const mockWindowLocation = {
1716
hash: '',
1817
} as Window['location'];
1918

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;
2519
// @ts-expect-error store a reference so we can reset it later
2620
const globalLocation = global.location;
2721

28-
console.log('\n\n WINDOW!! \n\n');
29-
console.log(WINDOW.location);
30-
console.log('\n\n');
3122
const resourceEntryName = 'https://example.com/assets/to/css';
3223

3324
describe('_addMeasureSpans', () => {
@@ -272,24 +263,15 @@ describe('_addResourceSpans', () => {
272263
});
273264

274265
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;
280266
// @ts-expect-error need to override global document
281-
global.location = dom.window.location;
267+
global.location = mockWindowLocation;
282268

283-
WINDOW.location = location;
269+
console.log('\n\n WINDOW origin!! \n\n');
270+
console.log(WINDOW.location.origin);
271+
console.log('\n\n');
284272
}
285273

286274
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;
291275
// @ts-expect-error need to override global document
292276
global.location = globalLocation;
293-
294-
WINDOW.location = originalWindowLocation;
295277
}

0 commit comments

Comments
 (0)