Skip to content

Commit 18a325a

Browse files
committed
test: fix revokeObjectURL mock in export tests
Add conditional creation of window.URL.revokeObjectURL in test setup since it doesn't exist in Jest's JSDOM environment. This prevents 'Property revokeObjectURL does not exist' errors during test execution.
1 parent c1f9541 commit 18a325a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

superset-frontend/src/utils/export.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,20 @@ beforeEach(() => {
7474
createObjectURLSpy = jest
7575
.spyOn(window.URL, 'createObjectURL')
7676
.mockReturnValue('blob:mock-url');
77-
revokeObjectURLSpy = jest
78-
.spyOn(window.URL, 'revokeObjectURL')
79-
.mockImplementation(() => {});
77+
78+
// Create revokeObjectURL if it doesn't exist
79+
if (!window.URL.revokeObjectURL) {
80+
window.URL.revokeObjectURL = jest.fn();
81+
}
82+
revokeObjectURLSpy = jest.spyOn(window.URL, 'revokeObjectURL');
8083
});
8184

8285
afterEach(() => {
8386
createElementSpy.mockRestore();
8487
createObjectURLSpy.mockRestore();
85-
revokeObjectURLSpy.mockRestore();
88+
if (revokeObjectURLSpy) {
89+
revokeObjectURLSpy.mockRestore();
90+
}
8691
});
8792

8893
test('exports resource with correct endpoint and headers', async () => {

0 commit comments

Comments
 (0)