Automated website audits with Lighthouse and QF-Test

What is Lighthouse?

Lighthouse, an open-source tool which was developed by Google, makes it possible to analyze your website in the four categories performance, accessibility, best practices and SEO. To analyze each category, Lighthouse runs a barrage of tests called audits. Depending on the results of the audits, the respective category will get a score between 0 and 100 (see Figure 1).

Figure 1: Lighthouse Scores Figure 1: Lighthouse Scores The performance category analyzes how quickly a website loads and how quickly users can access or view the content. The corresponding score will be influenced by metrics like First Contentful Paint or Time to Interactive. First Contentful Paint indicates the time before the first text or image becomes visible to users while Time to Interactive measures how long it takes a page to become fully interactive.

Accessibility ensures that people with disabilities can access content and navigate the site effectively. One audit used to determine this category’s score is checking whether images have been assigned an alt attribute. They allow reader programs to describe the image’s content for visually impaired people.

The third category makes sure that your site follows standard best practices for the web. For example, does it avoid deprecated APIs and does it only embed resources from secure sources?

Finally, SEO checks how well your page is optimized for search engine result rankings.

Integrate Lighthouse audits in QF-Test

The procedure allows you to define a warning and/or error limit between 0 and 100 for each of the four categories. For example, if the performance score is below the error limit you specify, QF-Test will alert you (see Figure 2). By setting the value of a limit parameter to -, you can also disable its checking.

Figure 2: Performance score fell below your error limit

Figure 2: Performance score fell below your error limit The attached test suite lighthouse.qft contains a procedure “checkLighthouseScores” to start lighthouse audits and check its results. With the help of the procedure’s parameters, you can define a warning and/or error limit for each of the four categories (Value must be between 0 and 100). If, let’s say, the performance score falls below your specified error limit, QF-Test will inform you with the respective error message (See Figure 2). To deactivate the check of a limit parameter, you just need to set its value to -.

By integrating Lighthouse audits into your automated testing, your site can be continuously checked for unexpected changes. Besides a summary that will be saved in the run log, the procedure also provides several optional parameters for further configuration. For example, the parameter “mobileEmulation” allows you to analyze your website not only in a desktop but also a smartphone environment.

How to install Lighthouse

The first step is to install the Google Chrome Browser, as Lighthouse analyzes your website using its headless mode.

To be able to execute the procedure, Lighthouse needs to be installed as a Node.js module.

  • Install the current long-term support version (LTS) of Node.js. The latest version can be downloaded from: https://nodejs.org/de
  • After Node.js is installed, please open the command line of your operating system (Windows: command prompt).
  • Use the opened command line to execute the command shown in figure 3. If Lighthouse should not be installed as a global module, do not use the -g flag. Figure 3: Install Lighthouse Figure 3: Install Lighthouse

  • To ensure correct installation, execute the command lighthouse in the already opened command line. Following output should appear: Figure 4: Lighthouse Output Figure 4: Lighthouse Output For further information regarding Lighthouse please visit: Lighthouse

Final hints

  • In case the lighthouse command cannot be found anyway, a missing entry in your path environment variable may be missing. On Windows you may add e.g. %appdata%\npm by hand.
  • After installing npm and lighthouse, QF-Test need to be restarted in order to get aware of changes in the envrionment settings.
  • Some lighthouse results are dependent on the network connection and machine performance, the audits are executed on. There should be no constraints or your need to take them into account respectively.

We use "Matomo" cookies to anonymously evaluate your visit to our website. For this we need your consent, which is valid for twelve months.

Cookie Configuration

Functional cookies

We use functional cookies to ensure the basic functionality of the website.

Performance and statistics cookies

We use Matomo for analyzing and optimizing our website. Cookies permit an anonymous collection of information that help us offering you a clear and user-friendly visit of our web pages.

Cookie details
Description Vendor Lifetime Type Purpose
_pk_id Matomo 13 Months HTTP Contains a unique, pseudonymized visitor ID internal to Matomo for recognizing returning visitors.
_pk_ref Matomo 6 Months HTTP Used to track from which website the anonymized user proceeded to our website.
_pk_ses Matomo 1 Day HTTP The Matomo session cookie is used to track the visitor's page requests during the session.
_pk_testcookie Matomo Session HTTP Used to check whether the visitor's browser supports cookies.
_pk_cvar Matomo 30 Minutes HTTP Temporarily store data about the visit.
_pk_hsr Matomo 30 Minutes HTTP Temporarily store data about the visit.