Skip to content

[P0] Stabilize the Vitest environment for pdfjs/react-pdf #8

@nkanf-dev

Description

@nkanf-dev

Summary

Fix the unit/UI test environment so pdfjs-dist and react-pdf dependencies do not crash the suite in jsdom.

Why

The current test environment fails with DOMMatrix is not defined, preventing the suite from validating actual logic changes.

Current evidence

  • npm run test:unit and UI tests fail before assertions run.
  • src/services/PDFService.ts and src/components/reader/ReaderViewport.tsx import PDF dependencies directly in test contexts.

Scope

  • Add the required polyfills or targeted mocks for DOMMatrix and related PDF primitives.
  • Isolate rendering-heavy dependencies so store/service tests do not load browser-only code unnecessarily.
  • Document the chosen strategy in test setup.
  • Keep the fix minimal and maintainable.

Acceptance criteria

  • Unit and UI test suites start reliably in jsdom.
  • PDF-related modules no longer crash test initialization.
  • The setup is documented and reproducible on CI.

Out of scope

  • Replacing react-pdf or pdfjs-dist entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions