pkgsite/e2e
Jamal Carvalho 45b240f298 content/static/homepage: use cropped gopher image
The old image file contained excess whitespace.
Switching to the cropped image and adusting styles
fit the new image size.

Change-Id: Idd0a3603192c5bd70c64c605746eb451afb21ae3
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/327290
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-11 21:55:30 +00:00
..
__image_snapshots__ content/static/homepage: use cropped gopher image 2021-06-11 21:55:30 +00:00
__snapshots__ e2e: update snapshots 2021-06-11 15:17:17 +00:00
docker devtools: copy ci/nodejs.sh to nodejs.sh 2021-06-11 20:13:42 +00:00
helpers content,internal: update pages to use new base layout 2021-06-07 15:09:35 +00:00
README.md devtools/e2e: add setup for running e2e in CI 2021-06-10 19:41:52 +00:00
basic.test.ts e2e: factor out common code for basic snapshots 2021-05-26 16:05:33 +00:00
errors.desktop.test.ts e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
global-types.ts e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
pkgsite.desktop.test.ts e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
pkgsite.mobile.test.ts e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
search.test.ts e2e: factor out common code for basic snapshots 2021-05-26 16:05:33 +00:00
setup.ts e2e: adjust snapshot failure threshold 2021-05-19 18:21:03 +00:00
test-environment.js e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
unit.desktop.test.ts e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
unit.mobile.test.ts e2e: reduce boilerplate and add additonal tests 2021-05-14 15:38:08 +00:00
unit.testcases.ts e2e: change test case to avoid pseudo-version 2021-05-21 18:25:44 +00:00

README.md

End-to-End (E2E) Tests

This directory contains end-to-end tests for pages on pkg.go.dev.

Running E2E Tests

In order to run the tests, run this command from the root of the repository:

$ ./e2e/docker/run.sh

./e2e/docker/run.sh sets up a series of docker containers that run a postgres database, frontend, and headless chrome, and runs the e2e tests using headless chrome.

Alternatively, you can run the tests against a website that is already running.

First run headless chrome:

docker run --rm -e "CONNECTION_TIMEOUT=-1" -p 3000:3000 browserless/chrome:1.46-chrome-stable

Then run the tests from the root of pkgsite:

./all.bash npx jest [files]

PKGSITE_URL can https://pkg.go.dev, or http://localhost:8080 if you have a local instance for the frontend running.

Understanding Test Failures

If the tests failure, diffs will be created that show the cause of the failure. Timeouts and diff thresholds are configurable for image snapshots if adjustments are needed to prevent test flakiness. See the API for jest image snapshots for more information.

Writing E2E Tests

Tests are written in the Jest framework using Puppeteer to drive a headless instance of Chrome.

Familiarize yourself with the Page class from the Puppeteer documenation. You'll find methods on this class that let you to interact with the page.

Most tests will follow a similar structure but for details on the Jest framework and the various hooks and assertions see the API.