Skip to content
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

Error with pixelmatch ES import into an ES Playwright test #143

Open
manudas opened this issue Nov 6, 2024 · 0 comments
Open

Error with pixelmatch ES import into an ES Playwright test #143

manudas opened this issue Nov 6, 2024 · 0 comments

Comments

@manudas
Copy link

manudas commented Nov 6, 2024

Hi there

I am trying to use Pixelmatch 6.0 (ES module pixelmatch) on a TS project

It shouldn't be a problem, however, when importing it in a Playwright test, I get this problem in the beginning of the test file (not even in the import statement):

Error: require() of ES Module C:\Sources\RTCP.DepTMS\WebClient\PlanReview\BlueEthos.Web.UI\node_modules\pixelmatch\index.js from C:\Sources\RTCP.DepTMS\WebClient\PlanReview\BlueEthos.Web.UI\playwright\tests\integration\plan-review.spec.ts not supported. Instead change the require of index.js in C:\Sources\RTCP.DepTMS\WebClient\PlanReview\BlueEthos.Web.UI\playwright\tests\integration\plan-review.spec.ts to a dynamic import() which is available in all CommonJS modules.playwright

image

Following the advice to use a dynamic import it works, but I don't understand why, as this is not a CommonJS module.

I've removed the @types/pixelmatch module as it was for a previous CommonJS version, but no luck.

What could be happening? this is a non sense.

Let me know if I can do some checks to find out what the problem is.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant