Fix: resolve dynamic import warnings during jest tests

This commit is contained in:
shamoon 2025-02-14 11:34:11 -08:00
parent a9ef7ff58e
commit 5e00c1c676
No known key found for this signature in database

View File

@ -120,3 +120,20 @@ Object.defineProperty(window, 'location', {
HTMLCanvasElement.prototype.getContext = <
typeof HTMLCanvasElement.prototype.getContext
>jest.fn()
// pdfjs
jest.mock('pdfjs-dist', () => ({
getDocument: jest.fn(() => ({
promise: Promise.resolve({ numPages: 3 }),
})),
GlobalWorkerOptions: { workerSrc: '' },
VerbosityLevel: { ERRORS: 0 },
globalThis: {
pdfjsLib: {
GlobalWorkerOptions: {
workerSrc: '',
},
},
},
}))
jest.mock('pdfjs-dist/web/pdf_viewer', () => ({}))