Command line tool for quickly running Lighthouse (https://developers.google.com/web/tools/lighthouse/) against a url.
Install the package globally to install the binary tool 'lh-cli'.
Alternatively, execute the main script in this package 'src/index.js.
-
lh-cli <target-url>
lh-cli http://www.example.com
-
./src/index.js <target-url>
./src/index.js http://www.example.com
Note that you need to include the protocol also.
Lighthouse will run against the specified url. The produced report will open in your browser once complete.
You can create automation tests to assert the performance threshold against any url, as determined by lighthouse.
yarn perf-test
will run a generic jest test which will utilise the test cases defined in test/suites.
See the test/suites folder for examples on how to create tests.
{
"base": "https://www.bbc.co.uk",
"paths": [
{
"name": "news page is quick",
"path": "/news",
"threshold": 40
},
{
"name": "weather page is quick",
"path": "/weather",
"threshold": 40
}
]
}
The included Dockerfile will build a container to include headless chrome and run the performance tests.
docker build -t lighthouse-automation .
docker run lighthouse-automation
This will build the container if required and then run it.
docker-compose up
A Jest test report will be output to the reports directory, along with lighthouse reports for each url tested.
Lighthouse reports will be in json and html format.