Back to Teleport

E2E Testing with Playwright

e2e/README.md

19.0.1-dev5.6 KB
Original Source

E2E Testing with Playwright

This directory contains end-to-end tests that run against a real Teleport instance using Playwright.

Setup

The runner will install the E2E dependencies and Playwright browsers for you on each run. You can also set up your environment manually if you prefer:

bash
pnpm install
pnpm exec playwright install chromium

Running Tests

Tests are run via the run.sh script, which builds and executes the Go test runner:

bash
./e2e/run.sh [flags] [test files...]

You can invoke this from either the e2e/ directory or the root of the repository (or any other directory, really) - the runner will rewrite any test-result/ paths to be relative to the current working directory, so you can still click through to screenshots and anything else from Playwright's test results.

Modes

By default, the runner runs in test mode. Use one of the following flags to change the mode (mutually exclusive):

FlagDescription
--uiOpen Playwright UI mode
--debugRun tests with Playwright inspector (PWDEBUG=1)
--codegenOpen Playwright codegen against running Teleport. Available only for web tests.
--browseOpen a signed-in browser for manual web testing
--browse-connectOpen a signed-in Teleport Connect app for manual testing

Flags

FlagDefaultDescription
-vfalseEnable debug logging
--no-buildfalseSkip make binaries (useful during development)
--quietfalseRedirect Teleport logs to file instead of stdout
--fullfalseEnable all optional fixtures
--replace-certsfalseGenerate new self-signed certificates
--update-snapshotsfalseUpdate Playwright snapshot baselines
--teleport-log-levelINFOTeleport log severity (DEBUG, INFO, WARN, ERROR)
--license-filePath to Teleport license file (required for Enterprise features)
--teleport-binbuild/teleportOverride teleport binary path (env: TELEPORT_BIN)
--tctl-binbuild/tctlOverride tctl binary path (env: TCTL_BIN)
--teleport-urlOverride Teleport URL (env: TELEPORT_URL). If set, the runner skips starting Teleport

Fixtures

FlagDescription
--with-ssh-nodeStart and connect a Teleport SSH node (runs in Docker)
--with-connectBuild Teleport Connect. Enabled by default when running tests in e2e/tests/connect

Common Commands

Typically, you'll want to run with --no-build during test development to skip rebuilding Teleport binaries on every run. --quiet is also useful to reduce the noise from Teleport logs. The logs are captured in teleport.log for debugging purposes.

Connect is built automatically when running tests/connect paths or when using --browse-connect, or --full.

bash
# Run a specific test, skip rebuilding (fastest iteration loop)
./e2e/run.sh --no-build e2e/tests/web/authenticated/roles.spec.ts

# Run only Connect tests, skip rebuilding of both Teleport and Connect
./e2e/run.sh --no-build e2e/tests/connect

# Open a browser with auth already set up for manual testing
./e2e/run.sh --browse

# Open Connect with auth already set up for manual testing
./e2e/run.sh --browse-connect

# Debug a failing test with the Playwright inspector
./e2e/run.sh --debug e2e/tests/web/authenticated/roles.spec.ts

# Open Playwright UI mode (pick and run tests interactively)
./e2e/run.sh --ui

# Record a new test by interacting with the browser
./e2e/run.sh --codegen

# Update snapshot baselines after a visual change
./e2e/run.sh --update-snapshots --with-ssh-node e2e/tests/web/with-ssh-node/ssh.spec.ts

More Examples

bash
# Run all tests
./e2e/run.sh

# Run SSH node tests with the fixture enabled
./e2e/run.sh --with-ssh-node e2e/tests/web/with-ssh-node/ssh.spec.ts

# Run tests with all fixtures enabled, skipping the Teleport build
./e2e/run.sh --full --no-build

# Run against an existing Teleport instance (doesn't work yet as authentication is hardcoded to the e2e setup and we need to figure out auth for remote instances)
./e2e/run.sh --teleport-url https://localhost:3080

# Set the Teleport log level to DEBUG for more verbose output
./e2e/run.sh --teleport-log-level DEBUG