mfrachet / cypress-audit

⚡ Run Lighthouse and Pa11y audits directly in your E2E test suites
https://mfrachet.github.io/cypress-audit/
MIT License
351 stars 44 forks source link

fix: lighthouse .cjs import and use legacy navigation #213

Closed MuckT closed 1 year ago

MuckT commented 1 year ago

Description

A follow up PR to fix #209 to use the .cjs import.

Fixes: #207

MuckT commented 1 year ago

@mfrachet when I update the import of lightHouseLib to .cjs in the examples/cra-authenticated/node_modules/@cypress-audit/lighthouse/src/task.js the tests are passing locally.

MuckT commented 1 year ago

@mfrachet is there a way the tests can use the local version of cypress-audit instead of the latest version on npm in the CI checks? This might make future PR's easier to contribute.

mfrachet commented 1 year ago

npm run bootstrap should do the trick with lerna and its workspaces (at the root of the project)

MuckT commented 1 year ago

@mfrachet ended up using relative imports in the example to make e2e testing easier with changes in 74e20476f19167ba60c16fa78633718a6017e179.

mfrachet commented 1 year ago

It has not worked with the workspaces?

Can you try the following pleas (using module imports) at the root:

and tell me if the workspace module resolution is working?

MuckT commented 1 year ago

@mfrachet I think I am getting the version 1.4.0 of cypress-audit in the tests if run the above commands run then run the tests locally.

Error [ERR_REQUIRE_ESM]: require() of ES Module /repos/cypress-audit/examples/cra-authenticated/node_modules/lighthouse/core/index.js from /repos/cypress-audit/examples/cra-authenticated/node_modules/@cypress-audit/lighthouse/src/task.js not supported.
Instead change the require of index.js in /repos/cypress-audit/examples/cra-authenticated/node_modules/@cypress-audit/lighthouse/src/task.js
mfrachet commented 1 year ago

Arg, you're PR works for me locally using the lerna bootstrap command, something weird is happening

MuckT commented 1 year ago

I'll revert those changes. It looks like a bunch of package-lock.json files got updated in doing so. Is that expected?

@mfrachet looks like those changes are failing in CI.

mfrachet commented 1 year ago

I just moved to pnpm + lerna in https://github.com/mfrachet/cypress-audit/pull/214 and cherry picked your changes regarding the commonjs fix. Let's cross the fingers that people using ESM will not inc too soon :p

Thanks for your help and patience on this one 🙏🏻 . I will merge the pnpm thing and iterate from there