-
Notifications
You must be signed in to change notification settings - Fork 0
Restore global.fetch after each test. #46
Copy link
Copy link
Open
Description
🧩 Analysis chain
🏁 Script executed:
cat -n src/components/GifFrameExtractor.test.tsxRepository: AStevensTaylor/image-tools
Length of output: 13605
Restore global.fetch after each test.
Multiple tests mock global.fetch without restoration, causing test isolation issues. Later tests will inherit the previous test's stub instead of the real fetch. Store originalFetch at module level and restore it in the existing afterEach hook, following the pattern already used for ImageDecoder restoration in this file.
Proposed fix
+const originalFetch = global.fetch;
+
beforeEach(() => {
localStorage.clear();
});
afterEach(() => {
localStorage.clear();
+ global.fetch = originalFetch;
});🤖 Prompt for AI Agents
In `@src/components/GifFrameExtractor.test.tsx` around lines 8 - 14, Store the
original global.fetch in a module-level variable (e.g. originalFetch) before
tests run and restore it in the existing afterEach hook alongside the
ImageDecoder cleanup; modify the test file so before any test stubs replace
global.fetch you assign originalFetch = global.fetch, and update afterEach() to
set global.fetch = originalFetch (and then clear localStorage as currently done)
to ensure fetch is restored between tests.
Originally posted by @coderabbitai[bot] in #44 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels