Skip to content

Commit 058a07c

Browse files
jtomaszewskiclaude
andauthored
fix(graphcache): use vi.stubGlobal for navigator mock in tests (#3838)
Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 1d0ce5c commit 058a07c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

exchanges/graphcache/src/offlineExchange.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Operation,
66
OperationResult,
77
} from '@urql/core';
8-
import { vi, expect, it, describe, beforeAll } from 'vitest';
8+
import { vi, expect, it, describe, beforeAll, afterAll } from 'vitest';
99

1010
import { pipe, share, map, makeSubject, tap, publish } from 'wonka';
1111
import { queryResponse } from '../../../packages/core/src/test-utils';
@@ -105,7 +105,11 @@ describe('storage', () => {
105105
describe('offline', () => {
106106
beforeAll(() => {
107107
vi.resetAllMocks();
108-
globalThis.navigator = { onLine: true } as any;
108+
vi.stubGlobal('navigator', { onLine: true });
109+
});
110+
111+
afterAll(() => {
112+
vi.unstubAllGlobals();
109113
});
110114

111115
it('should intercept errored mutations', () => {

0 commit comments

Comments
 (0)