This directory contains utility functions and infrastructure for TypeScript
tests that that make use of Puppeteer. Puppeteer is a
Node.js library that provides an API to instantiate and control a headless
Chromium browser. Most things that can be done manually in the browser can be
done using Puppeteer.
Examples of tests that make use of Puppeteer might include:
Screenshot-grabbing tests. In the case of lit-html components, such a test
might perform the following steps:
Load the component's demo page on a headless Chromium instance.
Perform some basic assertions on the structure of the webpage to make sure
it loads correctly.
Fire up a Go web server configured to use fake/mock instances of its
dependencies.
e.g. use the Firestore emulator instead of hitting GCP.
Ideally in a
hermetic
way for increased speed and reduced flakiness.
Drive the app with Puppeteer (e.g. by clicking on things, using the
browser's back and forward buttons, etc.). Make assertions along the way.
Optionally grab screenshots and upload them to Gold.
Test naming scheme
The recommended naming scheme for screenshots is
<application>_<component-name-sk>_<scenario>. This is to avoid name collisions
and to be consistent with existing tests.
For example, tests for Gold's dots-sk component are named as follows: