Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: change `global` -> `globalThis` in tests (#3590)

authored by

Marvin Hagemeister and committed by
GitHub
3ffe6fdc 88bed21c

+27 -27
+1 -1
exchanges/execute/src/execute.test.ts
··· 47 47 const expectedQueryOperationName = 'getUser'; 48 48 const expectedSubscribeOperationName = 'subscribeToUser'; 49 49 50 - const fetchMock = (global as any).fetch as Mock; 50 + const fetchMock = (globalThis as any).fetch as Mock; 51 51 const mockHttpResponseData = { key: 'value' }; 52 52 53 53 beforeEach(() => {
+2 -2
exchanges/graphcache/src/offlineExchange.test.ts
··· 105 105 describe('offline', () => { 106 106 beforeAll(() => { 107 107 vi.resetAllMocks(); 108 - global.navigator = { onLine: true } as any; 108 + globalThis.navigator = { onLine: true } as any; 109 109 }); 110 110 111 111 it('should intercept errored mutations', () => { 112 - const onlineSpy = vi.spyOn(navigator, 'onLine', 'get'); 112 + const onlineSpy = vi.spyOn(globalThis.navigator, 'onLine', 'get'); 113 113 114 114 const client = createClient({ 115 115 url: 'http://0.0.0.0',
+1 -1
packages/core/src/exchanges/debug.test.ts
··· 29 29 }); 30 30 31 31 it('forwards query operations correctly', async () => { 32 - vi.spyOn(global.console, 'log').mockImplementation(() => { 32 + vi.spyOn(globalThis.console, 'log').mockImplementation(() => { 33 33 /** Do NOthing */ 34 34 }); 35 35 const { source: ops$, next, complete } = input;
+3 -3
packages/core/src/exchanges/fetch.test.ts
··· 17 17 import { OperationResult } from '../types'; 18 18 import { fetchExchange } from './fetch'; 19 19 20 - const fetch = (global as any).fetch as Mock; 20 + const fetch = (globalThis as any).fetch as Mock; 21 21 const abort = vi.fn(); 22 22 23 23 const abortError = new Error(); 24 24 abortError.name = 'AbortError'; 25 25 26 26 beforeAll(() => { 27 - (global as any).AbortController = function AbortController() { 27 + (globalThis as any).AbortController = function AbortController() { 28 28 this.signal = undefined; 29 29 this.abort = abort; 30 30 }; ··· 36 36 }); 37 37 38 38 afterAll(() => { 39 - (global as any).AbortController = undefined; 39 + (globalThis as any).AbortController = undefined; 40 40 }); 41 41 42 42 const response = JSON.stringify({
+3 -3
packages/core/src/internal/fetchSource.test.ts
··· 16 16 import { OperationResult, Operation } from '../types'; 17 17 import { makeOperation } from '../utils'; 18 18 19 - const fetch = (global as any).fetch as Mock; 19 + const fetch = (globalThis as any).fetch as Mock; 20 20 const abort = vi.fn(); 21 21 22 22 beforeAll(() => { 23 - (global as any).AbortController = function AbortController() { 23 + (globalThis as any).AbortController = function AbortController() { 24 24 this.signal = undefined; 25 25 this.abort = abort; 26 26 }; ··· 32 32 }); 33 33 34 34 afterAll(() => { 35 - (global as any).AbortController = undefined; 35 + (globalThis as any).AbortController = undefined; 36 36 }); 37 37 38 38 const response = JSON.stringify({
+3 -3
packages/core/src/utils/variables.test.ts
··· 68 68 }); 69 69 70 70 it('stringifies plain objects from foreign JS contexts correctly', () => { 71 - const global: typeof globalThis = new Script( 71 + const scriptGlobal: typeof globalThis = new Script( 72 72 'exports = globalThis' 73 73 ).runInNewContext({}).exports; 74 74 75 - const plain = new global.Function('return { test: true }')(); 75 + const plain = new scriptGlobal.Function('return { test: true }')(); 76 76 expect(stringifyVariables(plain)).toBe('{"test":true}'); 77 77 78 - const data = new global.Function('return new (class Test {})')(); 78 + const data = new scriptGlobal.Function('return new (class Test {})')(); 79 79 expect(stringifyVariables(data)).toMatch(/^{"__key":"\w+"}$/); 80 80 }); 81 81 });
+1 -1
packages/preact-urql/src/components/Mutation.test.tsx
··· 20 20 beforeEach(() => { 21 21 vi.useFakeTimers(); 22 22 23 - vi.spyOn(global.console, 'error').mockImplementation(() => { 23 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 24 24 // do nothing 25 25 }); 26 26 });
+1 -1
packages/preact-urql/src/components/Query.test.tsx
··· 24 24 25 25 describe('Query', () => { 26 26 beforeEach(() => { 27 - vi.spyOn(global.console, 'error').mockImplementation(() => { 27 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 28 28 // do nothing 29 29 }); 30 30 });
+1 -1
packages/preact-urql/src/components/Subscription.test.tsx
··· 21 21 describe('Subscription', () => { 22 22 beforeEach(() => { 23 23 vi.useFakeTimers(); 24 - vi.spyOn(global.console, 'error').mockImplementation(() => { 24 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 25 25 // do nothing 26 26 }); 27 27 });
+1 -1
packages/preact-urql/src/hooks/useMutation.test.tsx
··· 39 39 }; 40 40 41 41 beforeAll(() => { 42 - vi.spyOn(global.console, 'error').mockImplementation(() => { 42 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 43 43 // do nothing 44 44 }); 45 45 });
+1 -1
packages/preact-urql/src/hooks/useQuery.test.tsx
··· 42 42 43 43 beforeEach(() => { 44 44 vi.useFakeTimers(); 45 - vi.spyOn(global.console, 'error'); 45 + vi.spyOn(globalThis.console, 'error'); 46 46 }); 47 47 48 48 describe('useQuery', () => {
+1 -1
packages/preact-urql/src/hooks/useSubscription.test.tsx
··· 41 41 }; 42 42 43 43 beforeAll(() => { 44 - vi.spyOn(global.console, 'error').mockImplementation(() => { 44 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 45 45 // do nothing 46 46 }); 47 47 });
+1 -1
packages/react-urql/src/components/Mutation.test.tsx
··· 31 31 beforeEach(() => { 32 32 vi.useFakeTimers(); 33 33 // TODO: Fix use of act() 34 - vi.spyOn(global.console, 'error').mockImplementation(() => { 34 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 35 35 // do nothing 36 36 }); 37 37 });
+1 -1
packages/react-urql/src/components/Query.test.tsx
··· 34 34 describe('Query', () => { 35 35 beforeEach(() => { 36 36 // TODO: Fix use of act() 37 - vi.spyOn(global.console, 'error').mockImplementation(() => { 37 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 38 38 // do nothing 39 39 }); 40 40 });
+1 -1
packages/react-urql/src/hooks/useMutation.test.tsx
··· 45 45 beforeEach(() => { 46 46 vi.useFakeTimers(); 47 47 48 - vi.spyOn(global.console, 'error').mockImplementation(() => { 48 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 49 49 // do nothing 50 50 }); 51 51
+1 -1
packages/react-urql/src/hooks/useQuery.spec.ts
··· 41 41 describe('useQuery', () => { 42 42 beforeAll(() => { 43 43 // TODO: Fix use of act() 44 - vi.spyOn(global.console, 'error').mockImplementation(() => { 44 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 45 45 // do nothing 46 46 }); 47 47 });
+1 -1
packages/react-urql/src/hooks/useQuery.test.tsx
··· 55 55 beforeEach(() => { 56 56 vi.useFakeTimers(); 57 57 // TODO: Fix use of act() 58 - vi.spyOn(global.console, 'error').mockImplementation(() => { 58 + vi.spyOn(globalThis.console, 'error').mockImplementation(() => { 59 59 // do nothings 60 60 }); 61 61
+3 -3
scripts/vitest/setup.js
··· 1 1 // This script is run before each `.test.ts` file. 2 2 import { vi } from 'vitest'; 3 3 4 - global.AbortController = undefined; 5 - global.fetch = vi.fn(); 4 + globalThis.AbortController = undefined; 5 + globalThis.fetch = vi.fn(); 6 6 7 7 process.on('unhandledRejection', error => { 8 8 throw error; 9 9 }); 10 10 11 11 const originalConsole = console; 12 - global.console = { 12 + globalThis.console = { 13 13 ...originalConsole, 14 14 warn: (vi.SpyInstance = () => { 15 15 /* noop */