-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
lighthouse Playwright- Instead change the require of index.js, to a dynamic import() which is available in all CommonJS modules #72
Comments
I am using the @playwright/test package as well with playwright-lighthouse and getting the same type of error:
I am importing the playwright-lighthouse package like this: And this is my tsconfig.json file:
|
As suggested on the stackoverflow link provided on #45, adding:
to my package.json solved the issue. |
What if someone does not want to add "type": "module" in their package.json because project is configured with commonjs? How can we use playwright-lighthouse if package type is not a module? |
Same issue. Suggestion with type in package.json not working |
I faced this issue, but I resolved it. I tried every suggestion on the web and no one is working. As far as the only solution I found is upgrading This is the solution: I'm using the version 1.46.0, then load the module async It is not an issue with this library, it is an issue with playwright and its module system. Some of their modules does not support common js To the author of this module: please add to the readme the note of this versions and the way to load it |
@alphonse92's response worked for me! |
What helped for me was to create a helper like this const dynamicImport = async (packageName: string) =>
new Function(`return import('${packageName}')`)();
export default dynamicImport; which I then used like so: |
0
I am trying to use lighthouse with my playwright cucumber project but getting below error::
.F--.
Failures:
√ Before # src\hooks\hooks.ts:19
× Given I am on the homepage # src\test\steps\ecomm\lighthouse.ts:34
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Playwright\node_modules\playwright-lighthouse\index.js from C:\Playwright\src\pages\example\exampleHomePage.ts not supported.
Instead change the require of index.js in C:\Playwright\src\pages\example\exampleHomePage.ts to a dynamic import() which is available in all CommonJS modules.
at require.extensions. [as .js] (C:Playwright\node_modules\ts-node\dist\index.js:851:20)
at C:Playwright\src\pages\example\exampleHomePage.ts:132:94
StepDef file :
ExampleHomePage:
The text was updated successfully, but these errors were encountered: