Skip to content

Commit c42a154

Browse files
ymc9claude
andcommitted
test(fetch-client): restore globalThis.fetch in afterEach
Save original fetch before mocking and restore it after each test to prevent cross-test pollution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1a4de21 commit c42a154

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/clients/fetch-client/test/fetch-client.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ function makeSerializedResponseText(data: unknown) {
1818

1919
describe('createClient', () => {
2020
let mockFetch: ReturnType<typeof vi.fn>;
21+
const originalFetch = globalThis.fetch;
2122

2223
beforeEach(() => {
2324
mockFetch = vi.fn();
2425
globalThis.fetch = mockFetch as unknown as typeof globalThis.fetch;
2526
});
2627

2728
afterEach(() => {
29+
globalThis.fetch = originalFetch;
2830
vi.resetAllMocks();
2931
});
3032

0 commit comments

Comments
 (0)