45b240f298
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> |
||
---|---|---|
.. | ||
__image_snapshots__ | ||
__snapshots__ | ||
docker | ||
helpers | ||
README.md | ||
basic.test.ts | ||
errors.desktop.test.ts | ||
global-types.ts | ||
pkgsite.desktop.test.ts | ||
pkgsite.mobile.test.ts | ||
search.test.ts | ||
setup.ts | ||
test-environment.js | ||
unit.desktop.test.ts | ||
unit.mobile.test.ts | ||
unit.testcases.ts |
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.