Open szamacz opened 1 year ago
getting this same issue as well. did you also end up with this issue after trying to downgrade the lighthouse version?
Finally we have some solutions for this? I'm having the same issue. Any workaround?
I'm just following the example on https://www.npmjs.com/package/playwright-lighthouse and I'm also having the same issue
npm install --save-dev playwright-lighthouse@2.2.2
you can use this version which works until there is a fix for this problem
npm install --save-dev playwright-lighthouse@2.2.2
you can use this version which works until there is a fix for this problem
Doing this and I still get the error
could anyone share a small repository where I can reproduce the same? Trying to resolve this by this week
I believe this should help you in reproducing the issue. https://vinayksharma.medium.com/lighthouse-integration-with-playwright-d2b58386f77 The documents is learning material to integrate playwright with lighthouse and sample script has been provided as well.
npm install --save-dev playwright-lighthouse@2.2.2
you can use this version which works until there is a fix for this problemDoing this and I still get the error
ahh ... for me it still works since i downgraded
@andreiancas22 , can you share the sample repo .
this is the code that i am running:
import { test } from '@playwright/test';
import { playAudit } from 'playwright-lighthouse';
import playwright from 'playwright';
import lighthouseDesktopConfig from 'lighthouse/lighthouse-core/config/lr-desktop-config';
test.describe('audit example', () => {
test('sample perf test', async () => {
const url = 'https://app.creatopy.com/';
const browser = await playwright['chromium'].launch({
args: ['--remote-debugging-port=9222']
});
const page = await browser.newPage();
await page.goto(url);
await page.waitForLoadState('networkidle');
await playAudit({
page: page,
config: lighthouseDesktopConfig,
thresholds: {
performance: 50,
accessibility: 50,
'best-practices': 50,
seo: 50
},
port: 9222,
reports: {
formats: {
json: true,
html: true
},
name: 'audit'
}
});
await browser.close();
});
});
and this is the output that i got after running the test:
package.json content
thanks @andreiancas22 , it worked with the mentioned lighthouse & playwright-lightout version in your package.json along with the @playwright/test version that you are using. Since , we are using playwright 1.35.0 as of now and we might need to wait for the proper solution with latest playwright-lighthouse version.
@sbettego glad that it helped, yea we need to wait for the playwright-lighthouse fix
So what should I do? Downgrading doesn't solve it for me.
npm install --saveDev lighthouse@9.6.8 playwright-lighthouse@2.2.2
worked for me. Broken on 10.4.0 / 3.1.0 respectively.
I'm also still encountering this issue even after downgrading to those versions
Looking into this issue. Will update here once I have something
Adding "type": "module",
to my package.json
fixed this issue.
Adding that to my package.json doesn't work. Is there any update on fixing this bug?
Hello? Any update?
yarn add -D lighthouse@9.6.8 playwright-lighthouse@2.2.2
worked for me 31.Oct.2023. If it get my test running I may be able look at the proper fix... any pointers would be appreciated.
@andreiancas22 Did you face issues trying to use the page
prop in the playAudit
method?
@andreiancas22 Did you face issues trying to use the
page
prop in theplayAudit
method?
no, it worked perfectly
@andreiancas22 @andrei22b
I found the error (after doing more research and thanks to GitHub Copilot jajaja), and it was the incompatibility of the page
value sent to the prop: playwright-lighthouse expects a Page object from playwright-core, not playwright
.
Instead of using the default playwright
import, I changed it to import { chromium, Page } from 'playwright-core'
, and it worked.
And, I downgraded the versions as suggested here: "lighthouse": "^9.6.8"
and "playwright-lighthouse": "^2.2.2"
.
Thanks! :D
Is there any update on this one? I've tried different combinations of package versions but still have the same error -
Error: require() of ES Module /node_modules/get-port/index.js from /workspaces/starter/next/playwright-tests/utils/index.ts not supported.
Instead change the require of index.js in /playwright-tests/utils/index.ts to a dynamic import() which is available in all CommonJS modules.
any updates?
Encountering the same problem here.. Just wondering what the status is
@stijnelskens adding "type": "module"
to the package.json helped for me. I used npx playwright init
to bootstrap the test suite for my app (which lives in another folder and has a separate package.json) so this worked fine but if you are integrating playwright into something already existing it might not work for you.
the module lighthouse/report/generator/report-generator
is now a ESmodule that make it incompatible with the current module system that is "commonJS" so, you need to import it via "import("lighthouse/report/generator/report-generator")"
I posted the solution here: https://github.com/abhinaba-ghosh/playwright-lighthouse/issues/72 if some of you are looking for info
After bumping the version from 2.2.2 to 31.1.0 Im getting an error flowing error in my project require() of ES Module playwright-lighthouse\index.js not supported. Playwright version - 1.35.1, lighthouse version - 10.3.0. I tried to set in package.json "type": "module", which removes the error but then playwright tests are not recognizable.