Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 191 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,192 @@
# test-automation-playwright-ts
A web test automation framework, powered by Playwright with TypeScript

[![Playwright Tests](https://img.shields.io/badge/playwright-%20test-blue)](https://playwright.dev/) [![TypeScript](https://img.shields.io/badge/TypeScript-%5E4.0-blue)](https://www.typescriptlang.org/) ![Status](https://img.shields.io/badge/status-draft-lightgrey)

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.

## Overview

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:
- Fast, reliable E2E tests using Playwright Test
- TypeScript-first developer experience
- Clear structure for tests, fixtures, and page objects
- Recommended CI integration and reproducible local runs
- Support for traces, videos, and HTML reports for debugging failures

---

## Prerequisites

- Node.js (up to v 22.20)
- TypeScript (up to 4.9.5)
- yarn (1.22.22)
- Playwright (>= 1.48.1)

---

## Quick start

1. Clone the repository
```bash
git clone https://github.com/nickIsNotUnique/test-automation-playwright-ts.git
cd test-automation-playwright-ts
```

2. Install dependencies and Playwright browsers
```bash
yarn install
yarn playwright install
```

3. Verify your installation by running the test suite
```bash
yarn playwright test
```

---

## Useful commands

- Run a single test file:
```bash
yarn playwright test tests/example.spec.ts
```
- Run with grep (run only tests that match a tag):
```bash
yarn playwright test --grep @smoke
```
- Debug a test with Playwright inspector:
```bash
yarn playwright test --debug
```

---

## Project structure

This section describes a used layout

- .github/workflows/ — CI workflows
- node_modules/
- playwright-report/
- test-results/
- tests/ — Test files (e.g., *.spec.ts)
- .gitignore
- package.json
- playwright.config.ts — Playwright test runner configuration
- README.md
- tsconfig.json
- yarn.lock

---

## CI: GitHub Actions

This project uses GitHub Actions for continuous integration.
Available pipelines:

### `playwright.yml` - Playwright Tests

**Triggers:**
- Push to `main` or `master` branches
- Pull Request to `main` or `master` branches

**Functions:**
- Checks out code from repository
- Sets up Node.js (latest LTS version)
- Installs dependencies via Yarn
- Installs Playwright browsers with all dependencies
- Runs all Playwright tests (`yarn playwright test`)
- Uploads test results as artifacts

**Results:**
- **Report**: Playwright HTML report saved as artifact named `playwright-report`
- **Retention**: artifacts stored for 30 days
- **Timeout**: maximum execution time - 60 minutes
- **Platform**: runs on Ubuntu Latest
- Artifacts uploaded even if tests are cancelled or fail

---

### `auto-simple-suite.yaml` - Auto run simple suite

**Triggers:**
- Pull Request to `main` branch
- Manual run via workflow_dispatch

**Functions:**
This workflow consists of **3 parallel jobs**:

#### Job 1: `run-simple-suite`
- Checks out code
- Sets up Node.js version 22 with Yarn caching
- Installs dependencies
- Installs Chromium browser only
- **Runs smoke tests**: `yarn playwright test --project=chromium --grep @smoke`
- Uploads test results

#### Job 2: `post-slack-notification-started`
- Sends Slack notification about **test execution start**
- Message: "The simple suite pipeline started"
- Uses webhook from `SLACK_WEBHOOK_URL` secret

#### Job 3: `post-slack-notification-results`
- Depends on `run-simple-suite` completion
- Always runs (if: always())
- Sends Slack notification with **execution result**:
- On success: "The simple suite pipeline succeeded"
- On failure: "The simple suite pipeline failed"

**Results:**
- **Report**: test results saved as `simple-suite-results-{run_id}`
- **Retention**: artifacts stored for 7 days
- **Timeout**: maximum execution time - 15 minutes
- **Platform**: Ubuntu Latest
- **Notifications**: automatic Slack notifications about start and results
- Artifacts uploaded even if tests are cancelled or fail

---

### `run-simple-suite.yaml` - Run simple suite

**Triggers:**
- Manual run only via workflow_dispatch

**Functions:**
- Identical to `run-simple-suite` job from the auto-simple-suite workflow
- Checks out code
- Sets up Node.js version 22 with Yarn caching
- Installs dependencies
- Installs Chromium browser only
- **Runs smoke tests**: `yarn playwright test --project=chromium --grep @smoke`
- Uploads test results

**Results:**
- **Report**: test results saved as `simple-suite-results-{run_id}`
- **Retention**: artifacts stored for 7 days
- **Timeout**: maximum execution time - 15 minutes
- **Platform**: Ubuntu Latest
- **No Slack notifications**
- Artifacts uploaded even if tests are cancelled or fail

---

### Comparison table:

| Feature | playwright.yml | auto-simple-suite.yaml | run-simple-suite.yaml |
|---------|----------------|------------------------|----------------------|
| **Auto-trigger** | Push/PR | PR to main | No |
| **Manual trigger** | No | Yes | Yes |
| **Tests** | All | @smoke only | @smoke only |
| **Browsers** | All | Chromium | Chromium |
| **Timeout** | 60 min | 15 min | 15 min |
| **Artifact retention** | 30 days | 7 days | 7 days |
| **Slack notifications** | No | Yes | No |
| **Node.js** | LTS | v22 | v22 |

---

## Resources

- Playwright docs: https://playwright.dev/
- Playwright GitHub examples: https://github.com/microsoft/playwright
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default defineConfig({
// baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
trace: process.env.CI ? 'on' : 'retain-on-failure',
},

/* Configure projects for major browsers */
Expand Down
Loading