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

add cypress-audits to execute lighthouse during end-2-end tests #14681

Merged
merged 12 commits into from
May 15, 2021

Conversation

atomfrede
Copy link
Member

Right now the cypress audit uses desktop emulation and no cpu slowdown. With 4x cpu slowdown I get very bad results with angular, so I am not sure what happens in our CI with the current thresholds, especially when the frontend is not packaged in prod mode. Maybe we can add an environment variable to skip audits (e.g. when running in dev mode).

Closes #14615


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (bellow reviewers) and adding skip-ci label, you can still see CI build result at your branch.

@atomfrede
Copy link
Member Author

Looks like some configs passes the audit some not (guess somehow depends on the shared runner). I think it would be best to have a dedicated command e.g. npm run audits which just executes the audit spec while the default cypress run does not.

Copy link
Member

@mshima mshima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results seem to change a lot each run.
That may be related to virtual environment shared resources.

So IMO it should be optional and disabled by default.
A test enabling it should be discussed separately, probably an application with no entity with focus on pwa.

@mshima
Copy link
Member

mshima commented Apr 15, 2021

Looks like some configs passes the audit some not (guess somehow depends on the shared runner). I think it would be best to have a dedicated command e.g. npm run audits which just executes the audit spec while the default cypress run does not.

A custom command would be great too.

@atomfrede
Copy link
Member Author

The results seem to change a lot each run.
That may be related to virtual environment shared resources.

So IMO it should be optional and disabled by default.
A test enabling it should be discussed separately, probably an application with no entity with focus on pwa.

I did not expect such results, but yes I will disable it by default and it must be started e.g. with npm run e2e:audits or so. Maybe separate the specs also by name would make it easier.

-%>
describe('Audits', () => {
beforeEach(() => {
cy.visit('/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we are trying to calculate the lighthouse score for the application landing page (/ route). For more comprehensive coverage, we should do that for each route in our application.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you expect huge differences between them? But of course that could be extended.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I don't know. I haven't looked into cypress audits and it's capabilities. Do you have assertions to check on best practices? If yes, then, you may want to run the audit for each page.

In the svelte blueprint, I used a different approach and the integration is only in the CI (not in generated code). You can of course do that in the generated code, but that was not the concern that I want to handle at moment.

@atomfrede atomfrede force-pushed the 14615-continous-lighthouse-audits branch from 49130cb to f84506c Compare May 14, 2021 13:11
atomfrede and others added 3 commits May 14, 2021 15:12
…ns/index.ts.ejs

Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
…ns/index.ts.ejs

Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
@atomfrede
Copy link
Member Author

I have changed it such that

  • audits are in .audits.ts
  • dedicated cypress config only executing *.audits.ts files
  • dedicated commands, e.g. cypress:audits which opens cypress with the audits configuration
  • also updated the readme which did not contain anything about e2e tests when using cypress yet

@atomfrede atomfrede requested review from mraible and mshima May 14, 2021 13:27
@atomfrede atomfrede force-pushed the 14615-continous-lighthouse-audits branch from 8b25335 to 4b6c6b2 Compare May 14, 2021 21:15
Copy link
Member

@mshima mshima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to remove whitespaces, but removed lines.

LGTM.

@atomfrede
Copy link
Member Author

Thanks @mshima for your review. you are awesome!

@atomfrede atomfrede merged commit b743958 into jhipster:main May 15, 2021
@atomfrede
Copy link
Member Author

@pascalgrimaud
Copy link
Member

@atomfrede : approved

@pascalgrimaud pascalgrimaud added this to the 7.1.0 milestone May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Lighthouse to Cypress tests to identify performance regressions
5 participants