Skip to content

Commit d58ea55

Browse files
author
Thor011
committed
Initial commit: Playwright API Test Framework with Cucumber/BDD
- 76 Gherkin scenarios (409 steps) covering comprehensive API testing - Advanced patterns: HTTP protocol, identity, sorting, pagination, idempotency, performance, data quality - Contract validation for external API testing - Authentication examples (Bearer, API Key, Basic Auth) - Complete documentation with guides - CI/CD workflow with GitHub Actions - MIT License
0 parents  commit d58ea55

36 files changed

Lines changed: 4833 additions & 0 deletions

.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# API Test Environment Variables
2+
# Copy this file to .env and fill in your actual values
3+
4+
# API Configuration
5+
API_BASE_URL=https://jsonplaceholder.typicode.com
6+
7+
# Authentication
8+
API_BEARER_TOKEN=your-bearer-token-here
9+
API_KEY=your-api-key-here
10+
11+
# OAuth (if needed)
12+
OAUTH_CLIENT_ID=your-client-id
13+
OAUTH_CLIENT_SECRET=your-client-secret
14+
OAUTH_TOKEN_URL=https://oauth.example.com/token
15+
16+
# Test Configuration
17+
TEST_TIMEOUT=30000
18+
PARALLEL_WORKERS=4

.github/copilot-instructions.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# API Test Framework - Project Instructions
2+
3+
## Project Overview
4+
Playwright API test framework with TypeScript for comprehensive REST API testing.
5+
6+
## Technology Stack
7+
- **Framework**: Playwright (API testing)
8+
- **Language**: TypeScript
9+
- **Test Runner**: Playwright Test
10+
- **Reporters**: HTML, JSON
11+
12+
## Project Structure
13+
- `/tests` - API test files
14+
- `/tests/helpers` - Helper functions and utilities
15+
- `/tests/config` - Configuration files
16+
- `playwright.config.ts` - Playwright configuration
17+
18+
## Development Guidelines
19+
- Write tests using async/await pattern
20+
- Use Playwright's APIRequestContext for HTTP calls
21+
- Organize tests by API endpoint or feature
22+
- Include authentication examples
23+
- Validate response status, headers, and body
24+
25+
## Test Execution
26+
- Run all tests: `npx playwright test`
27+
- Run specific test: `npx playwright test <filename>`
28+
- Run with UI: `npx playwright test --ui`
29+
- Generate report: `npx playwright show-report`
30+
31+
## Coding Standards
32+
- Use TypeScript strict mode
33+
- Follow async/await best practices
34+
- Add meaningful test descriptions
35+
- Include assertions for status codes and data

.github/workflows/api-tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: API Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
timeout-minutes: 10
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '18'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Install Playwright browsers
29+
run: npx playwright install chromium
30+
31+
- name: Run API tests
32+
run: npm test
33+
34+
- name: Upload test results
35+
uses: actions/upload-artifact@v3
36+
if: always()
37+
with:
38+
name: playwright-report
39+
path: playwright-report/
40+
retention-days: 7
41+
42+
- name: Upload test results JSON
43+
uses: actions/upload-artifact@v3
44+
if: always()
45+
with:
46+
name: test-results
47+
path: test-results/
48+
retention-days: 7

.github/workflows/test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: API Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
timeout-minutes: 10
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
node-version: [18.x, 20.x]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Setup Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Install Playwright browsers
32+
run: npx playwright install --with-deps
33+
34+
- name: Run Playwright tests
35+
run: npm test
36+
37+
- name: Run Cucumber tests
38+
run: npm run test:cucumber
39+
40+
- name: Upload Playwright report
41+
uses: actions/upload-artifact@v4
42+
if: always()
43+
with:
44+
name: playwright-report-${{ matrix.node-version }}
45+
path: playwright-report/
46+
retention-days: 30
47+
48+
- name: Upload Cucumber report
49+
uses: actions/upload-artifact@v4
50+
if: always()
51+
with:
52+
name: cucumber-report-${{ matrix.node-version }}
53+
path: cucumber-report.html
54+
retention-days: 30

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Test results
5+
/test-results/
6+
/playwright-report/
7+
/blob-report/
8+
/playwright/.cache/
9+
10+
# Cucumber reports
11+
cucumber-report.html
12+
cucumber-report.json
13+
14+
# Environment variables
15+
.env
16+
.env.local
17+
.env.*.local
18+
19+
# Logs
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
# OS files
26+
.DS_Store
27+
Thumbs.db
28+
29+
# IDE
30+
.vscode/
31+
.idea/
32+
*.swp
33+
*.swo
34+
*~
35+
36+
# Build output
37+
dist/
38+
build/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.11.0

0 commit comments

Comments
 (0)