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 · 7 comments
Open

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

manudas opened this issue Nov 6, 2024 · 7 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

@Med002rewired
Copy link

My device is hacked and its legal licence is charged

@manudas
Copy link
Author

manudas commented Dec 5, 2024

?

@Med002rewired
Copy link

Devices - A list of devices (i.e.PDF

@manudas
Copy link
Author

manudas commented Dec 5, 2024

I don't know what are you talking about and I don't understand why are you sending random PDFs with no real content

@marcusNumminen
Copy link

marcusNumminen commented Dec 18, 2024

I get similar problems, I get this:
(node:2923) ExperimentalWarning: CommonJS module /home/vsts/work/1/s/src/fixtures/testFixture.ts is loading ES Module /home/vsts/work/1/s/node_modules/pixelmatch/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

Any suggestions to get rid of this?

I started to get this "warning" when I updated to use node 22.12.0 and the latest version of the pixelmatch lib

@wizardpisces
Copy link

Same issue, fallback to version 5 solve my problem

@wizardpisces
Copy link

After read changeLog of V6 " Breaking: publish pixelmatch as a ES module. Use the older v5.3.0 if you need to support CommonJS environments. "

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

4 participants