-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Jest / use of ES modules dynamic import in SDK #426
Comments
Thanks for the issue! Hopefully one day Jest will catch up to ESM. Until then, we've removed the dynamic import (fixed in #430 & released in v2.0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apologies if this isn’t the best place to report this! I couldn’t find information about Jest support anywhere in official resources so I’m not sure whether this would be considered a bug or not.
The problem
In #411, the import of SDK utils has been switched to use an ES modules dynamic import. This is problematic for users of Jest, because Jest uses Node’s VM API to execute code. The VM modules API for ES modules support is experimental (only available behind the
--experimental-vm-modules
feature flag).For the Puppeteer SDK – this means v2.0.0 works fine in Jest, and v2.0.1 doesn’t work, with the following error when running
percySnapshot
:Environment
@percy/cli
version: v1.1.2@percy/[email protected]
If needed, a build or snapshot ID:Details
Jest has experimental support for ES modules, so this can be resolved by adding the correct feature flag for Node to expose its
vm.Module
API. I believe there are a few things worth addressing in the SDK nonetheless (assuming the SDK attempts to support Jest):Debug logs
The only relevant bit is the stack trace.
Code to reproduce issue
I can provide a small reproduction case once confirmed Jest is indeed supported.
Workarounds
For people running into this, there are three possible workarounds:
Revert to v2.0.0 of the Puppeteer SDK
It works.
Run the v2.0.1 SDK with Node flag
Following Jest’s documentation. Here is what it looks like:
This will output a lot of warning messages.
Use
@percy/sdk-utils
directlyThe code of v2.0.0 of the SDK can be copy-pasted and tweaked as needed to improve Jest support.
The text was updated successfully, but these errors were encountered: