Common Issues Integrating into Test Suites
This article lists common issues that might occur while integrating PSPDFKit for Web into your test suites.
PSPDFKit for Web makes use of multiple Web APIs. Some of them might not be present on a standard Node.js runtime or provided by DOM emulation environments such as jsdom, which is used by default on testing frameworks such as Jest.
While integrating PSPDFKit for Web with your tests, you might see an error like the following:
ReferenceError: x is not defined on import PSPDFKit from 'pspdfkit'.
x might be a reference to some standard DOM API member, and this means the Node.js environment your test suite is running on does not support it.
In this case, you’ll need to provide a mock for the missing member. You can either create a mock by yourself or look into an open source mock implementation for the missing API.
As an example, if you’re using Jest for your tests and observe a
TextMetrics is not defined error, you can add the
jest-canvas-mock package to your project and the error should be gone, since that package contains mocks for
canvas and related APIs, including