Skip to content

Commit 217c652

Browse files
gtamanahaalexs-mparticle
authored andcommitted
fix(tests): Replace global references from 'global' to 'globalThis' in apiClient tests for improved compatibility
1 parent ab2cec7 commit 217c652

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/jest/apiClient.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jest.mock('../../src/uploaders', () => {
1616
upload = xhrUploadMock;
1717
}
1818

19-
(global as any).__fetchUploadSpy = fetchUploadMock;
20-
(global as any).__xhrUploadSpy = xhrUploadMock;
19+
(globalThis as any).__fetchUploadSpy = fetchUploadMock;
20+
(globalThis as any).__xhrUploadSpy = xhrUploadMock;
2121

2222
return {
2323
AsyncUploader: class {},
@@ -69,22 +69,22 @@ describe('apiClient.sendLogToServer', () => {
6969
// @ts-ignore
7070
(global as any).window = {};
7171

72-
const fetchSpy = (global as any).__fetchUploadSpy as jest.Mock;
73-
const xhrSpy = (global as any).__xhrUploadSpy as jest.Mock;
72+
const fetchSpy = (globalThis as any).__fetchUploadSpy as jest.Mock;
73+
const xhrSpy = (globalThis as any).__xhrUploadSpy as jest.Mock;
7474
if (fetchSpy) fetchSpy.mockClear();
7575
if (xhrSpy) xhrSpy.mockClear();
7676
});
7777

7878
afterEach(() => {
79-
(global as any).window = originalWindow;
79+
(globalThis as any).window = originalWindow;
8080
if (originalFetch !== undefined) {
81-
(global as any).window.fetch = originalFetch;
81+
(globalThis as any).window.fetch = originalFetch;
8282
}
8383
jest.clearAllMocks();
8484
});
8585

8686
test('should use FetchUploader if window.fetch is available', () => {
87-
(global as any).window.fetch = jest.fn();
87+
(globalThis as any).window.fetch = jest.fn();
8888

8989
const uploadSpy = (global as any).__fetchUploadSpy as jest.Mock;
9090
const client = new APIClient(mpInstance, kitBlocker);

0 commit comments

Comments
 (0)