I'll help you create a comprehensive project structure for E2E automation testing that follows best practices and incorporates all your required technologies. Let me plan this out first.
e2e-automation/
├── .github/
│ └── workflows/
│ ├── main.yml # Main CI workflow
│ └── scheduled-tests.yml # Scheduled test runs
│
├── src/
│ ├── fixtures/ # Playwright test fixtures
│ │ ├── auth.fixture.ts
│ │ └── api.fixture.ts
│ │
│ ├── pages/ # Page Object Models
│ │ ├── base.page.ts # Base page with common methods
│ │ └── components/ # Reusable page components
│ │ ├── header.component.ts
│ │ └── footer.component.ts
│ │
│ ├── features/ # Cucumber feature files
│ │ ├── auth/
│ │ │ ├── login.feature
│ │ │ └── registration.feature
│ │ └── checkout/
│ │ └── payment.feature
│ │
│ ├── step-definitions/ # Cucumber step definitions
│ │ ├── auth.steps.ts
│ │ └── checkout.steps.ts
│ │
│ ├── api/ # API testing modules
│ │ ├── clients/ # API clients
│ │ │ ├── base.api.ts
│ │ │ └── auth.api.ts
│ │ └── schemas/ # API response schemas
│ │ └── auth.schema.ts
│ │
│ ├── helpers/ # Utility functions
│ │ ├── test.helper.ts
│ │ └── api.helper.ts
│ │
│ └── types/ # TypeScript type definitions
│ └── api.types.ts
│
├── test-data/ # Test data files
│ ├── users.json
│ └── products.json
│
├── config/ # Configuration files
│ ├── playwright.config.ts # Playwright configuration
│ └── cucumber.js # Cucumber configuration
│
├── reports/ # Test reports directory
│ └── .gitkeep
│
├── package.json
├── tsconfig.json
├── .env.example # Environment variables template
├── .gitignore
└── README.md
Key configuration files content:
# package.json:
{
"name": "e2e-automation",
"version": "1.0.0",
"scripts": {
"test": "cucumber-js",
"test:api": "cucumber-js --tags @api",
"test:e2e": "cucumber-js --tags @e2e",
"test:parallel": "cucumber-js --parallel 3",
"report": "generate-cucumber-report",
"lint": "eslint . --ext .ts",
"format": "prettier --write \"**/*.{ts,json,md}\""
},
"dependencies": {
"@cucumber/cucumber": "^latest",
"@playwright/test": "^latest",
"typescript": "^latest"
}
}
playwright.config.ts:
import { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
testDir: './src',
timeout: 30000,
retries: 2,
workers: 3,
use: {
baseURL: process.env.BASE_URL,
screenshot: 'only-on-failure',
video: 'retain-on-failure',
trace: 'retain-on-failure'
},
projects: [
{
name: 'Chrome',
use: { browserName: 'chromium' }
},
{
name: 'Firefox',
use: { browserName: 'firefox' }
}
]
};
export default config;
.github/workflows/main.yml:
name: E2E Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Run tests
run: npm run test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: reports/
I've created a comprehensive project structure that follows the Page Object Model pattern and incorporates all your required technologies. Here are some key aspects of the structure:
-
Test Organization:
- Features and step definitions are separated for better maintainability
- Page Objects are organized with a base page and reusable components
- API tests are structured with separate clients and schemas
-
Key Features:
- Playwright fixtures for handling common setup/teardown
- Support for parallel test execution
- API and E2E tests separation using Cucumber tags
- Comprehensive GitHub Actions CI setup
- Environment-based configuration
-
Best Practices:
- Type definitions for better TypeScript support
- Separate test data management
- Configurable reporting
- Reusable helpers and utilities
- Clear separation of concerns
-
Added Benefits:
- Support for multiple browsers in configuration
- Automatic screenshot and video capture on failure
- Retry mechanism for flaky tests
- Parallel execution support
- Artifact upload in CI
Would you like me to explain any specific part of the structure in more detail or provide example code for any of the components?