|
1 | | -## Teleport E2E Tests |
| 1 | +# E2E Testing with Playwright |
2 | 2 |
|
3 | | -This directory contains end-to-end tests for Teleport. These tests are |
4 | | -designed to be run against a live cluster. They are written in TS and use |
5 | | -[Playwright](https://playwright.dev/) to interact with the browser. |
6 | | -Docker compose is used to spin up a cluster for testing and to run the tests. |
| 3 | +This directory contains the configuration and tests for end-to-end testing against a real Teleport instance using Playwright. |
7 | 4 |
|
8 | | -### Running the tests |
9 | | -```bash |
10 | | -# Make all removes the existing docker volumes to ensure a clean state |
11 | | -# and rebuild the containers |
12 | | -make all |
13 | | -``` |
14 | | -or |
| 5 | +E2E tests should be run by a corresponding Go test in `web-e2e_test.go` and run |
| 6 | +using `make test-web-e2e`. To run only the Playwright test directly, you'll need a Teleport instance running locally. |
| 7 | + |
| 8 | +Any test that involves an authenticated user should be run with a `START_URL` env variable that contains an invite link for the test user, this should be generated and provided by the corresponding Go test. |
| 9 | + |
| 10 | +### Setup |
| 11 | + |
| 12 | +Before being able to run any tests, you'll need to install the playwright package and the chromium browser. |
15 | 13 |
|
16 | 14 | ```bash |
17 | | -# Only run tests |
18 | | -make test |
| 15 | +# Install packages |
| 16 | +pnpm install |
| 17 | + |
| 18 | +# Install the Chromium browser |
| 19 | +pnpm exec playwright install chromium |
19 | 20 | ``` |
20 | 21 |
|
21 | | -### MacOS building notes |
| 22 | +## Running Tests |
22 | 23 |
|
23 | | -Before running the tests on MacOS in Docker, you need to build Linux compatible binaries. |
24 | | -Binaries are build using our Docker images inside `build.assets` directory. You can also |
25 | | -build them manually using `make build-binaries` command. |
| 24 | +### Basic Commands |
26 | 25 |
|
27 | | -### Running tests for development |
| 26 | +```bash |
| 27 | +# Run a test with the default START_URL (https://localhost:3080/web/login) |
| 28 | +pnpm test signup.spec.ts |
28 | 29 |
|
29 | | -Docker compose setup is designed to run tests in CI and create the same environment |
30 | | -locally, so debugging potential issues is easier. E2E tests make changes to the cluster, |
31 | | -so the order of the tests is important. To run tests for development, you can use |
32 | | -`yarn test` command to run the test against the existing cluster. |
33 | | -`yarn codegen` starts the Playwright codegen tool that allows to record the test |
34 | | -and generate the code for it. This improves the development speed as most code can be generated. |
| 30 | +# Run a test with a specific START_URL. |
| 31 | +START_URL=https://teleport.dev pnpm test signup.spec.ts |
35 | 32 |
|
36 | | -### Common issues |
| 33 | +# Run tests with the Playwright UI, useful for debugging. |
| 34 | +pnpm test --ui |
37 | 35 |
|
38 | | -`Cannot run macOS (Mach-O) executable in Docker: Exec format error` |
| 36 | +# Start the Playwright codegen to generate tests by recording your browser interactions. |
| 37 | +pnpm exec playwright codegen |
39 | 38 |
|
40 | | -This error means that you are trying to run MacOS binary on Linux. You need to build |
41 | | -Linux compatible binaries to run them in Docker. You can rebuild them using `make build-binaries` |
42 | | -or just remove existing binaries in `../build` as they will be rebuilt automatically. |
| 39 | +# View past test reports. |
| 40 | +pnpm report |
| 41 | +``` |
0 commit comments