Skip to content

Commit 313a6f7

Browse files
fix(internal): clean up undefined File test (#29)
1 parent 2bc2cb6 commit 313a6f7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Diff for: tests/uploads.test.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ function mockResponse({ url, content }: { url: string; content?: Blob }): Respon
1414
};
1515
}
1616

17-
beforeEach(() => {
18-
// The file shim captures the global File object when it's first imported.
19-
// Reset modules before each test so we can test the error thrown when it's undefined.
20-
jest.resetModules();
21-
});
22-
2317
describe('toFile', () => {
2418
it('throws a helpful error for mismatched types', async () => {
2519
await expect(
@@ -80,11 +74,23 @@ describe('toFile', () => {
8074
});
8175

8276
describe('missing File error message', () => {
77+
let prevFile: unknown;
8378
beforeEach(() => {
79+
// The file shim captures the global File object when it's first imported.
80+
// Reset modules before each test so we can test the error thrown when it's undefined.
81+
jest.resetModules();
82+
// @ts-ignore
83+
prevFile = globalThis.File;
8484
// @ts-ignore
8585
globalThis.File = undefined;
8686
require('node:buffer').File = undefined;
8787
});
88+
afterEach(() => {
89+
// Clean up
90+
// @ts-ignore
91+
globalThis.File = prevFile;
92+
jest.resetModules();
93+
});
8894

8995
test('is thrown', async () => {
9096
const uploads = await import('lightswitch-api/uploads');

0 commit comments

Comments
 (0)