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
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module",
"project": true
},
"plugins": ["@typescript-eslint", "playwright"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:playwright/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "warn"
},
"env": {
"node": true,
"es2022": true
},
"ignorePatterns": ["node_modules/", "test-results/", "playwright-report/", "*.config.ts"]
}
8 changes: 4 additions & 4 deletions .github/actions/setup-playwright/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ runs:
with:
node-version: '22'
cache: 'yarn'

- name: Install dependencies
run: yarn install
shell: bash

- name: Cache Playwright browsers
id: cache-playwright
uses: actions/cache@v4
Expand All @@ -23,8 +23,8 @@ runs:
restore-keys: |
playwright-browsers-${{ runner.os }}-
save-always: true

- name: Install Playwright browsers
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: yarn playwright install --with-deps
shell: bash
shell: bash
6 changes: 3 additions & 3 deletions .github/workflows/auto-simple-suite-reusable.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Auto run simple suite with reusable setup

on:
pull_request:
branches: [ main ]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -41,4 +41,4 @@ jobs:
with:
job_status: ${{ needs.run-simple-suite.result }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
14 changes: 7 additions & 7 deletions .github/workflows/auto-simple-suite.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Auto run simple suite

on:
pull_request:
branches: [ main ]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Post a start message in a Slack channel
env:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
curl -X POST -H 'Content-type: application/json' \
Expand All @@ -49,19 +49,19 @@ jobs:

post-slack-notification-results:
runs-on: ubuntu-latest
needs: run-simple-suite
needs: run-simple-suite
if: always()
steps:
- name: Post a result message in a Slack channel
env:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
if [ "${{ needs.run-simple-suite.result }}" == "success" ]; then
MESSAGE="The simple suite pipeline succeeded"
elif [ "${{ needs.run-simple-suite.result }}" == "failure" ]; then
MESSAGE="The simple suite pipeline failed"
fi

curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$MESSAGE\"}" \
$SLACK_WEBHOOK_URL
$SLACK_WEBHOOK_URL
36 changes: 18 additions & 18 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
branches: [main, master]
pull_request:
branches: [ main, master ]
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
2 changes: 1 addition & 1 deletion .github/workflows/run-daily-regression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
with:
name: regression-tests-results-${{ steps.date.outputs.date }}-${{ matrix.project }}-${{ github.run_id }}-${{ github.run_attempt }}
path: playwright-report/
retention-days: 30
retention-days: 30
6 changes: 3 additions & 3 deletions .github/workflows/run-p0-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Run P0 tests

on:
pull_request:
branches: [ main ]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -40,4 +40,4 @@ jobs:
with:
job_status: ${{ needs.run-p0-tests.result }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
6 changes: 3 additions & 3 deletions .github/workflows/run-smoke-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Run smoke tests

on:
pull_request:
branches: [ main ]
pull_request:
branches: [main]
paths:
- 'playwright.config.ts'
- 'package.json'
Expand Down Expand Up @@ -38,4 +38,4 @@ jobs:
with:
name: smoke-tests-results-${{ matrix.project }}-${{ github.run_id }}
path: playwright-report/
retention-days: 7
retention-days: 7
6 changes: 3 additions & 3 deletions .github/workflows/slack-notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Post message to Slack
env:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
PIPELINE_NAME="${{ github.workflow }}"

case "${{ inputs.job_status }}" in
"started") MESSAGE="🚀 $PIPELINE_NAME started" ;;
"success") MESSAGE="✅ $PIPELINE_NAME succeeded" ;;
Expand All @@ -29,7 +29,7 @@ jobs:
"skipped") MESSAGE="⏭️ $PIPELINE_NAME was skipped" ;;
*) MESSAGE="⚠️ $PIPELINE_NAME - status: ${{ inputs.job_status }}" ;;
esac

curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$MESSAGE\"}" \
$SLACK_WEBHOOK_URL
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
test-results/
playwright-report/
yarn.lock
package-lock.json
*.log

8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2,
"printWidth": 100,
"arrowParens": "always"
}
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This repository serves as a **practical demonstration** of implementing Playwrig
## 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
- Recommended CI integration and reproducible local runs
Expand Down Expand Up @@ -34,12 +35,14 @@ This repository demonstrates a pragmatic setup for automated UI tests using Play
## 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
Expand Down Expand Up @@ -70,6 +73,7 @@ This repository demonstrates a pragmatic setup for automated UI tests using Play
```bash
yarn playwright show-report
```

---

## Project structure
Expand All @@ -91,20 +95,24 @@ This section describes the project layout

## CI: GitHub Actions

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

### `playwright.yml` - Playwright Tests

#### Summary:

- Runs on every push to main/master
- Executes complete test coverage
- Ideal for: Release validation, nightly builds

**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
Expand All @@ -113,6 +121,7 @@ Available pipelines:
- 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
Expand All @@ -122,20 +131,24 @@ Available pipelines:
---

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

#### Summary:

- Triggers on PRs to main
- Runs critical path tests only
- Includes Slack notifications
- Ideal for: PR validation, quick feedback loops

**Triggers:**

- Pull Request to `main` branch
- Manual run via workflow_dispatch

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

#### Job 1: `run-simple-suite`

- Checks out code
- Sets up Node.js version 22 with Yarn caching
- Installs dependencies
Expand All @@ -144,18 +157,21 @@ This workflow consists of **3 jobs**:
- 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
Expand All @@ -166,15 +182,19 @@ This workflow consists of **3 jobs**:
---

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

#### Summary:

- Manually triggered via GitHub UI
- No notifications (focused testing)
- Ideal for: Ad-hoc testing, debugging, demos

**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
Expand All @@ -184,6 +204,7 @@ This workflow consists of **3 jobs**:
- 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
Expand All @@ -205,6 +226,7 @@ This project is part of my article series "Playwright testing with GitHub Action
## Feedback & Contributions

Questions or suggestions? Feel free to:

- [Open an issue](https://github.com/nickIsNotUnique/test-automation-playwright-ts/issues)
- [Start a discussion](https://github.com/nickIsNotUnique/test-automation-playwright-ts/discussions)
- ⭐ Star this repo if you find it useful!
Expand Down
Loading
Loading