|
1 | 1 | # test-automation-playwright-ts |
2 | | -A web test automation framework, powered by Playwright with TypeScript |
| 2 | + |
| 3 | +[](https://playwright.dev/) [](https://www.typescriptlang.org/)  |
| 4 | + |
| 5 | +A starter/test automation repository using Playwright with TypeScript. This project provides patterns, recommended configuration, and examples for end-to-end web testing with Playwright test runner, TypeScript, and modern CI practices. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +This repository demonstrates a pragmatic setup for automated UI tests using Playwright and TypeScript. It is intended as a foundation you can adapt to your own product tests. Key goals: |
| 10 | +- Fast, reliable E2E tests using Playwright Test |
| 11 | +- TypeScript-first developer experience |
| 12 | +- Clear structure for tests, fixtures, and page objects |
| 13 | +- Recommended CI integration and reproducible local runs |
| 14 | +- Support for traces, videos, and HTML reports for debugging failures |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- Node.js (up to v 22.20) |
| 21 | +- TypeScript (up to 4.9.5) |
| 22 | +- yarn (1.22.22) |
| 23 | +- Playwright (>= 1.48.1) |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Quick start |
| 28 | + |
| 29 | +1. Clone the repository |
| 30 | + ```bash |
| 31 | + git clone https://github.com/nickIsNotUnique/test-automation-playwright-ts.git |
| 32 | + cd test-automation-playwright-ts |
| 33 | + ``` |
| 34 | + |
| 35 | +2. Install dependencies and Playwright browsers |
| 36 | + ```bash |
| 37 | + yarn install |
| 38 | + yarn playwright install |
| 39 | + ``` |
| 40 | + |
| 41 | +3. Verify your installation by running the test suite |
| 42 | + ```bash |
| 43 | + yarn playwright test |
| 44 | + ``` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Useful commands |
| 49 | + |
| 50 | +- Run a single test file: |
| 51 | + ```bash |
| 52 | + yarn playwright test tests/example.spec.ts |
| 53 | + ``` |
| 54 | +- Run with grep (run only tests that match a tag): |
| 55 | + ```bash |
| 56 | + yarn playwright test --grep @smoke |
| 57 | + ``` |
| 58 | +- Debug a test with Playwright inspector: |
| 59 | + ```bash |
| 60 | + yarn playwright test --debug |
| 61 | + ``` |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## Project structure |
| 66 | + |
| 67 | +This section describes a used layout |
| 68 | + |
| 69 | +- .github/workflows/ — CI workflows |
| 70 | +- node_modules/ |
| 71 | +- playwright-report/ |
| 72 | +- test-results/ |
| 73 | +- tests/ — Test files (e.g., *.spec.ts) |
| 74 | +- .gitignore |
| 75 | +- package.json |
| 76 | +- playwright.config.ts — Playwright test runner configuration |
| 77 | +- README.md |
| 78 | +- tsconfig.json |
| 79 | +- yarn.lock |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## CI: GitHub Actions |
| 84 | + |
| 85 | +This project uses GitHub Actions for continuous integration. |
| 86 | +Available pipelines: |
| 87 | + |
| 88 | +### `playwright.yml` - Playwright Tests |
| 89 | + |
| 90 | +**Triggers:** |
| 91 | +- Push to `main` or `master` branches |
| 92 | +- Pull Request to `main` or `master` branches |
| 93 | + |
| 94 | +**Functions:** |
| 95 | +- Checks out code from repository |
| 96 | +- Sets up Node.js (latest LTS version) |
| 97 | +- Installs dependencies via Yarn |
| 98 | +- Installs Playwright browsers with all dependencies |
| 99 | +- Runs all Playwright tests (`yarn playwright test`) |
| 100 | +- Uploads test results as artifacts |
| 101 | + |
| 102 | +**Results:** |
| 103 | +- **Report**: Playwright HTML report saved as artifact named `playwright-report` |
| 104 | +- **Retention**: artifacts stored for 30 days |
| 105 | +- **Timeout**: maximum execution time - 60 minutes |
| 106 | +- **Platform**: runs on Ubuntu Latest |
| 107 | +- Artifacts uploaded even if tests are cancelled or fail |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +### `auto-simple-suite.yaml` - Auto run simple suite |
| 112 | + |
| 113 | +**Triggers:** |
| 114 | +- Pull Request to `main` branch |
| 115 | +- Manual run via workflow_dispatch |
| 116 | + |
| 117 | +**Functions:** |
| 118 | +This workflow consists of **3 parallel jobs**: |
| 119 | + |
| 120 | +#### Job 1: `run-simple-suite` |
| 121 | +- Checks out code |
| 122 | +- Sets up Node.js version 22 with Yarn caching |
| 123 | +- Installs dependencies |
| 124 | +- Installs Chromium browser only |
| 125 | +- **Runs smoke tests**: `yarn playwright test --project=chromium --grep @smoke` |
| 126 | +- Uploads test results |
| 127 | + |
| 128 | +#### Job 2: `post-slack-notification-started` |
| 129 | +- Sends Slack notification about **test execution start** |
| 130 | +- Message: "The simple suite pipeline started" |
| 131 | +- Uses webhook from `SLACK_WEBHOOK_URL` secret |
| 132 | + |
| 133 | +#### Job 3: `post-slack-notification-results` |
| 134 | +- Depends on `run-simple-suite` completion |
| 135 | +- Always runs (if: always()) |
| 136 | +- Sends Slack notification with **execution result**: |
| 137 | + - On success: "The simple suite pipeline succeeded" |
| 138 | + - On failure: "The simple suite pipeline failed" |
| 139 | + |
| 140 | +**Results:** |
| 141 | +- **Report**: test results saved as `simple-suite-results-{run_id}` |
| 142 | +- **Retention**: artifacts stored for 7 days |
| 143 | +- **Timeout**: maximum execution time - 15 minutes |
| 144 | +- **Platform**: Ubuntu Latest |
| 145 | +- **Notifications**: automatic Slack notifications about start and results |
| 146 | +- Artifacts uploaded even if tests are cancelled or fail |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +### `run-simple-suite.yaml` - Run simple suite |
| 151 | + |
| 152 | +**Triggers:** |
| 153 | +- Manual run only via workflow_dispatch |
| 154 | + |
| 155 | +**Functions:** |
| 156 | +- Identical to `run-simple-suite` job from the auto-simple-suite workflow |
| 157 | +- Checks out code |
| 158 | +- Sets up Node.js version 22 with Yarn caching |
| 159 | +- Installs dependencies |
| 160 | +- Installs Chromium browser only |
| 161 | +- **Runs smoke tests**: `yarn playwright test --project=chromium --grep @smoke` |
| 162 | +- Uploads test results |
| 163 | + |
| 164 | +**Results:** |
| 165 | +- **Report**: test results saved as `simple-suite-results-{run_id}` |
| 166 | +- **Retention**: artifacts stored for 7 days |
| 167 | +- **Timeout**: maximum execution time - 15 minutes |
| 168 | +- **Platform**: Ubuntu Latest |
| 169 | +- **No Slack notifications** |
| 170 | +- Artifacts uploaded even if tests are cancelled or fail |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +### Comparison table: |
| 175 | + |
| 176 | +| Feature | playwright.yml | auto-simple-suite.yaml | run-simple-suite.yaml | |
| 177 | +|---------|----------------|------------------------|----------------------| |
| 178 | +| **Auto-trigger** | Push/PR | PR to main | No | |
| 179 | +| **Manual trigger** | No | Yes | Yes | |
| 180 | +| **Tests** | All | @smoke only | @smoke only | |
| 181 | +| **Browsers** | All | Chromium | Chromium | |
| 182 | +| **Timeout** | 60 min | 15 min | 15 min | |
| 183 | +| **Artifact retention** | 30 days | 7 days | 7 days | |
| 184 | +| **Slack notifications** | No | Yes | No | |
| 185 | +| **Node.js** | LTS | v22 | v22 | |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## Resources |
| 190 | + |
| 191 | +- Playwright docs: https://playwright.dev/ |
| 192 | +- Playwright GitHub examples: https://github.com/microsoft/playwright |
0 commit comments