Skip to content

Commit 2eded46

Browse files
committedMar 4, 2025
fix(tests): manually reset node:buffer File (#52)
1 parent e1e0fb5 commit 2eded46

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎tests/uploads.test.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,25 @@ describe('toFile', () => {
7474
});
7575

7676
describe('missing File error message', () => {
77-
let prevFile: unknown;
77+
let prevGlobalFile: unknown;
78+
let prevNodeFile: unknown;
7879
beforeEach(() => {
7980
// The file shim captures the global File object when it's first imported.
8081
// Reset modules before each test so we can test the error thrown when it's undefined.
8182
jest.resetModules();
83+
const buffer = require('node:buffer');
8284
// @ts-ignore
83-
prevFile = globalThis.File;
85+
prevGlobalFile = globalThis.File;
86+
prevNodeFile = buffer.File;
8487
// @ts-ignore
8588
globalThis.File = undefined;
86-
require('node:buffer').File = undefined;
89+
buffer.File = undefined;
8790
});
8891
afterEach(() => {
8992
// Clean up
9093
// @ts-ignore
91-
globalThis.File = prevFile;
94+
globalThis.File = prevGlobalFile;
95+
require('node:buffer').File = prevNodeFile;
9296
jest.resetModules();
9397
});
9498

0 commit comments

Comments
 (0)
Please sign in to comment.