Performance Testing
If you don’t want users leaving the app you have to think of performance. In fact nowadays if you site is not fast enough you get even “honored” with the badge of shame from Google. Thus performance budget is one of the aspects we address with end-to-end tests and include in CI/CD pipeline to ensure new releases do comply our requirements.
With Puppetry we can assert that:
- Page loading times comply given restrictions
- Total weight of assets (JavaScript, CSS, images, media, fonts, XHR) requested on the page satisfies given budget.
- Total number of requested of assets satisfies given budget
With
page.assertPerformanceTiming
method we can establish budget for loading times. Namely:- Page loading: the whole process of navigation and page load
- Redirection: the time taken by document request redirections
- Network latency: the time taken to fetch app cache, lookup domain, establish TCP connection, send request, receive response
- Page processing: the time taken for page load once the page is received from the server

Asserting page loading times
In case of assertion failure we get a report like this:

Page loading budget report
With
page.assertPerformanceAssetWeight
method we can assert the total weight of assets (JavaScript, CSS, images, media, fonts, XHR) requested on the page
Asserting total weight of requested assets
In case of assertion failure we get a report like this:

Assertion failed
By clicking on Download performance report

Download performance report button
we can get the network activity details

Performance report as a text file
With
page.assertPerformanceAssetCount
method we can assert the total number of assets (JavaScript, CSS, images, media, fonts, XHR) requested on the page
Asserting total number of requested assets
Last modified 3yr ago