{"id":15381909,"url":"https://github.com/justinribeiro/lighthouse-jest-example","last_synced_at":"2025-02-28T08:30:31.099Z","repository":{"id":44147677,"uuid":"181037888","full_name":"justinribeiro/lighthouse-jest-example","owner":"justinribeiro","description":"Sample using lighthouse and puppeteer with jest to run tests on your project/site.","archived":false,"fork":false,"pushed_at":"2023-01-04T21:43:15.000Z","size":1617,"stargazers_count":33,"open_issues_count":14,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-05T10:01:34.631Z","etag":null,"topics":["jest","lighthouse","puppeteer","webpagetest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinribeiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-12T15:44:00.000Z","updated_at":"2023-09-18T15:31:34.000Z","dependencies_parsed_at":"2023-02-02T21:00:34.417Z","dependency_job_id":null,"html_url":"https://github.com/justinribeiro/lighthouse-jest-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-jest-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-jest-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-jest-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-jest-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinribeiro","download_url":"https://codeload.github.com/justinribeiro/lighthouse-jest-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219871287,"owners_count":16560630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jest","lighthouse","puppeteer","webpagetest"],"created_at":"2024-10-01T14:29:13.215Z","updated_at":"2024-10-16T19:03:40.616Z","avatar_url":"https://github.com/justinribeiro.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lighthouse-jest-example\n\u003e Using lighthouse and puppeteer with jest to run tests on your project/site.\n\nBasic example that gathers performance metrics via [Lighthouse](https://github.com/GoogleChrome/lighthouse) and tests results with [Jest](https://jestjs.io/). Uses [Puppeteer](https://github.com/GoogleChrome/puppeteer) to start up come with Chrome with [network emulation settings defined by WebPageTest](https://github.com/WPO-Foundation/webpagetest/blob/master/www/settings/connectivity.ini.sample).\n\n![image](https://user-images.githubusercontent.com/643503/56050862-d451ec80-5d01-11e9-94df-04af4aaedf9e.png)\n\n## The basics\n\n```bash\n$ git clone git@github.com:justinribeiro/lighthouse-jest-example.git\n$ cd lighthouse-jest-example\n$ yarn\n```\n\n## If you want to test a local site\n\nWithin `utilities/jestStartup.js`, I start a local web server to test a local site. If you're testing on remotes or in more realistic envs, you can remove this startup.\n\nIf you want to test locally with that server however, you'll need to install the basic cert to get around invalid cert errors. There are two yarn commands for this purpose:\n\n```javascript\n// package.json / scripts\n\"ws:trustcert:linux\": \"certutil -d sql:$HOME/.pki/nssdb -A -t \\\"P,,\\\" -n ./node_modules/lws/ssl/lws-cert.pem -i ./node_modules/lws/ssl/lws-cert.pem\",\n\"ws:removecert:linux\": \"certutil -D -d sql:$HOME/.pki/nssdb -n -devcert\"\n```\n\nAs you see, you'll need certutil for you OS. I have not tested this on Windows or OS X, but if you have a command that works, PR's welcome.\n\n## Just let me test a site\n\nEach test within `test/performance` folder has it's own url you define. Yes, you could make this global to all tests if you like, but for this example, I was testing site variations so it's a little separated out.\n\nFrom there, you just run the tests:\n\n```bash\n$ yarn test:lighthouse\n# jest output here\n```\n\n## What if I don't want to use Puppeteer and those network settings?\n\nYou can use [chrome-launcher](https://github.com/GoogleChrome/chrome-launcher) within that method instead.\n\n## Is that going to give me a perfect result with that network emulation?\n\nNo. You should always measure on actual devices and connections if possible. I prefer the [comcast go package](https://github.com/tylertreat/comcast) personally.\n\nPlease see the [Advanced Throttling guide](https://github.com/GoogleChrome/lighthouse/blob/master/docs/throttling.md) in the Lighthouse repo.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinribeiro%2Flighthouse-jest-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinribeiro%2Flighthouse-jest-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinribeiro%2Flighthouse-jest-example/lists"}