Skip to content

Commit f80273e

Browse files
authored
Merge pull request #1 from sirajvind/stage
feat: add Playwright automation setup with README, GitHub Actions, and initial tests
2 parents 78bd391 + cd4ee6f commit f80273e

File tree

7 files changed

+325
-2
lines changed

7 files changed

+325
-2
lines changed

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npx playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: ${{ !cancelled() }}
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 10

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Node Modules
2+
node_modules/
3+
.npm/
4+
5+
# Logs
6+
*.log
7+
logs/
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
pnpm-debug.log*
12+
13+
# OS Generated Files
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Environment Variables
18+
.env
19+
.env.local
20+
.env.*.local
21+
22+
# Playwright Specific
23+
playwright-report/
24+
test-results/
25+
screenshots/
26+
trace/
27+
playwright/.cache/
28+
29+
# Cypress Specific
30+
cypress/screenshots/
31+
cypress/videos/
32+
33+
# IDE and Editor Files
34+
.idea/
35+
.vscode/
36+
*.sublime-project
37+
*.sublime-workspace
38+
39+
# Output and Coverage Files
40+
dist/
41+
coverage/

README.md

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
1-
# playwright-automation
2-
Automated UI & API testing suite using Playwright for end-to-end testing.
1+
<p align="center">
2+
<img src="https://playwright.dev/img/playwright-logo.svg" alt="Playwright Logo" width="200"/>
3+
</p>
4+
5+
6+
# Playwright Automation
7+
This project is an automated UI and API testing suite that utilizes [Playwright](https://playwright.dev/) for comprehensive end-to-end testing. Playwright is a robust framework that supports testing across multiple browsers, including Chromium, Firefox, and WebKit. With Playwright, you can ensure that your web applications perform consistently and reliably across different environments.
8+
9+
### Key Benefits:
10+
11+
- **Cross-Browser Testing**: Write tests that run on different browsers to ensure compatibility and performance.
12+
- **End-to-End Testing**: Validate the entire workflow of your application, from the user interface to backend services.
13+
- **UI Testing**: Automate interactions with your application's user interface to verify that it behaves as expected.
14+
- **API Testing**: Test your backend APIs to ensure they return the correct responses and handle edge cases.
15+
- **Headless Testing**: Execute tests in a headless browser mode for faster performance and integration into CI/CD pipelines.
16+
- **Debugging Tools**: Utilize Playwright's powerful debugging tools to troubleshoot and resolve issues quickly.
17+
18+
By integrating Playwright into your testing strategy, you can achieve higher test coverage, reduce manual testing efforts, and deliver a more reliable product to your users.
19+
20+
## Table of Contents
21+
22+
- [Features](#features)
23+
- [Installation](#installation)
24+
- [Usage](#usage)
25+
- [License](#license)
26+
27+
## Features
28+
29+
- **End-to-End Testing**: Test your entire application from start to finish.
30+
- **UI Testing**: Ensure your user interface works as expected.
31+
- **API Testing**: Validate your backend services.
32+
- **Headless Testing**: Run tests in a headless browser for faster execution.
33+
- **Debugging**: Easily debug your tests with Playwright's built-in tools.
34+
35+
## Installation
36+
37+
To get started with this project, clone the repository and install the dependencies:
38+
39+
```bash
40+
git clone https://github.com/yourusername/playwright-automation.git
41+
cd playwright-automation
42+
```
43+
```bash
44+
npm install
45+
```
46+
47+
> **Note:** Make sure you have [Node.js](https://nodejs.org/) and `npm` installed on your machine before running the above command.
48+
49+
## Usage
50+
51+
You can run the tests using the following commands:
52+
53+
Run All Tests
54+
55+
```bash
56+
npm test
57+
```
58+
59+
Run Tests with UI
60+
61+
```bash
62+
npm run test:ui
63+
```
64+
65+
Run Tests in Headed Mode
66+
67+
```bash
68+
npm run test:head
69+
```
70+
71+
Debug Tests
72+
73+
```bash
74+
npm run test:debug
75+
```
76+
77+
Generate Code
78+
79+
```bash
80+
npm run test:codegen
81+
```
82+
83+
## License
84+
85+
This project is licensed under the ISC License. See the [LICENSE](LICENSE) file for more details.

package-lock.json

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "playwright-automation",
3+
"version": "1.0.0",
4+
"description": "Automated UI &amp; API testing suite using Playwright for end-to-end testing.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "npx playwright test",
8+
"test:ui": "npx playwright test --ui",
9+
"test:head": "npx playwright test --headed",
10+
"test:debug": "npx playwright test --debug",
11+
"test:codegen": "npx playwright codegen"
12+
},
13+
"keywords": [],
14+
"author": "",
15+
"license": "ISC",
16+
"devDependencies": {
17+
"@playwright/test": "^1.49.0",
18+
"@types/node": "^22.10.1"
19+
}
20+
}

playwright.config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './tests',
5+
fullyParallel: true,
6+
forbidOnly: !!process.env.CI,
7+
retries: process.env.CI ? 2 : 0,
8+
workers: process.env.CI ? 1 : undefined,
9+
reporter: 'html',
10+
use: {
11+
trace: 'on-first-retry',
12+
},
13+
14+
projects: [
15+
{
16+
name: 'chromium',
17+
use: { ...devices['Desktop Chrome'] },
18+
},
19+
20+
{
21+
name: 'firefox',
22+
use: { ...devices['Desktop Firefox'] },
23+
},
24+
25+
{
26+
name: 'webkit',
27+
use: { ...devices['Desktop Safari'] },
28+
},
29+
],
30+
31+
/* Run your local dev server before starting the tests */
32+
// webServer: {
33+
// command: 'npm run start',
34+
// url: 'http://127.0.0.1:3000',
35+
// reuseExistingServer: !process.env.CI,
36+
// },
37+
});

tests/example.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('https://playwright.dev/');
5+
6+
// Expect a title "to contain" a substring.
7+
await expect(page).toHaveTitle(/Playwright/);
8+
});
9+
10+
test('get started link', async ({ page }) => {
11+
await page.goto('https://playwright.dev/');
12+
13+
// Click the get started link.
14+
await page.getByRole('link', { name: 'Get started' }).click();
15+
16+
// Expects page to have a heading with the name of Installation.
17+
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
18+
});

0 commit comments

Comments
 (0)