Skip to content

Commit 5e7e6ac

Browse files
Phase-1 Error Handling CICD Multi browser and environment handling and better hooks in place
1 parent a36acc7 commit 5e7e6ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3745
-372
lines changed

.env

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Environment Configuration
2+
TEST_ENV=dev
3+
NODE_ENV=development
4+
5+
# Application URLs
6+
BASE_URL=https://www.saucedemo.com/
7+
STAGING_URL=https://staging.saucedemo.com/
8+
PROD_URL=https://www.saucedemo.com/
9+
10+
# Browser Configuration
11+
BROWSER=chromium
12+
HEADLESS=false
13+
SLOW_MO=0
14+
TIMEOUT=30000
15+
RETRIES=2
16+
17+
# Viewport Settings
18+
VIEWPORT_WIDTH=1920
19+
VIEWPORT_HEIGHT=1080
20+
21+
# Parallel Execution
22+
PARALLEL_WORKERS=1
23+
24+
# Video Recording
25+
VIDEO_RECORDING=true
26+
VIDEO_MODE=retain-on-failure
27+
28+
# Screenshots
29+
SCREENSHOT_ON_FAILURE=true
30+
31+
# Tracing
32+
TRACE_ENABLED=true
33+
TRACE_MODE=retain-on-failure
34+
35+
# Logging
36+
LOG_LEVEL=info
37+
38+
# Test Data (if needed)
39+
# DEFAULT_USERNAME=standard_user
40+
# DEFAULT_PASSWORD=secret_sauce
41+
42+
# CI/CD Specific (optional)
43+
CI=false

.env.example

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Environment Configuration
2+
TEST_ENV=dev
3+
NODE_ENV=development
4+
5+
# Application URLs
6+
BASE_URL=https://www.saucedemo.com/
7+
STAGING_URL=https://staging.saucedemo.com/
8+
PROD_URL=https://www.saucedemo.com/
9+
10+
# Browser Configuration
11+
BROWSER=chromium
12+
HEADLESS=false
13+
SLOW_MO=0
14+
TIMEOUT=30000
15+
RETRIES=2
16+
17+
# Viewport Settings
18+
VIEWPORT_WIDTH=1920
19+
VIEWPORT_HEIGHT=1080
20+
21+
# Parallel Execution
22+
PARALLEL_WORKERS=1
23+
24+
# Video Recording
25+
VIDEO_RECORDING=true
26+
VIDEO_MODE=retain-on-failure
27+
28+
# Screenshots
29+
SCREENSHOT_ON_FAILURE=true
30+
31+
# Tracing
32+
TRACE_ENABLED=true
33+
TRACE_MODE=retain-on-failure
34+
35+
# Logging
36+
LOG_LEVEL=info
37+
38+
# Test Data (if needed)
39+
# DEFAULT_USERNAME=standard_user
40+
# DEFAULT_PASSWORD=secret_sauce
41+
42+
# CI/CD Specific (optional)
43+
CI=false
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Playwright Cucumber Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
inputs:
10+
environment:
11+
description: 'Environment to run tests against'
12+
required: true
13+
default: 'staging'
14+
type: choice
15+
options:
16+
- dev
17+
- staging
18+
- prod
19+
browser:
20+
description: 'Browser to run tests on'
21+
required: true
22+
default: 'chromium'
23+
type: choice
24+
options:
25+
- chromium
26+
- firefox
27+
- webkit
28+
- all
29+
parallel:
30+
description: 'Number of parallel workers'
31+
required: false
32+
default: '2'
33+
34+
jobs:
35+
test:
36+
runs-on: ubuntu-latest
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
browser: ${{ github.event.inputs.browser == 'all' && fromJSON('["chromium", "firefox", "webkit"]') || fromJSON(format('["{0}"]', github.event.inputs.browser || 'chromium')) }}
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '18'
50+
cache: 'npm'
51+
52+
- name: Install dependencies
53+
run: npm ci
54+
55+
- name: Install Playwright browsers
56+
run: npx playwright install --with-deps ${{ matrix.browser }}
57+
58+
- name: Create .env file
59+
run: |
60+
echo "TEST_ENV=${{ github.event.inputs.environment || 'ci' }}" >> .env
61+
echo "BROWSER=${{ matrix.browser }}" >> .env
62+
echo "HEADLESS=true" >> .env
63+
echo "PARALLEL_WORKERS=${{ github.event.inputs.parallel || '2' }}" >> .env
64+
echo "VIDEO_RECORDING=true" >> .env
65+
echo "VIDEO_MODE=on-first-retry" >> .env
66+
echo "SCREENSHOT_ON_FAILURE=true" >> .env
67+
echo "TRACE_ENABLED=true" >> .env
68+
echo "TRACE_MODE=retain-on-failure" >> .env
69+
echo "CI=true" >> .env
70+
71+
- name: Run tests
72+
run: npm run test:ci
73+
env:
74+
BROWSER: ${{ matrix.browser }}
75+
TEST_ENV: ${{ github.event.inputs.environment || 'ci' }}
76+
77+
- name: Upload test results
78+
if: always()
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: test-results-${{ matrix.browser }}
82+
path: |
83+
test-results/
84+
logs/
85+
retention-days: 30
86+
87+
- name: Upload Playwright traces
88+
if: failure()
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: traces-${{ matrix.browser }}
92+
path: test-results/traces/
93+
retention-days: 7
94+
95+
- name: Upload screenshots
96+
if: failure()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: screenshots-${{ matrix.browser }}
100+
path: test-results/screenshots/
101+
retention-days: 7
102+
103+
- name: Upload videos
104+
if: failure()
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: videos-${{ matrix.browser }}
108+
path: test-results/videos/
109+
retention-days: 7
110+
111+
- name: Publish test report
112+
if: always()
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: cucumber-report-${{ matrix.browser }}
116+
path: test-results/reports/
117+
retention-days: 30
118+
119+
notify:
120+
needs: test
121+
runs-on: ubuntu-latest
122+
if: always()
123+
steps:
124+
- name: Send notification
125+
run: |
126+
echo "Tests completed with status: ${{ needs.test.result }}"
127+
# Add your notification logic here (Slack, Teams, Email, etc.)

0 commit comments

Comments
 (0)