Based on the repository structure and files you've provided, here's a comprehensive README.md for your Playwright testing repository:
# Playwright Testing Suite
A comprehensive test automation project using [Playwright](https://playwright.dev/), a modern end-to-end testing framework that supports Chromium, Firefox, and WebKit browsers.
## π Project Overview
This repository contains automated tests for web applications, including:
- **Basic Example Tests**: Simple test cases demonstrating Playwright fundamentals
- **Todo App Tests**: Comprehensive test suite for a demo TodoMVC application
- **Multi-browser Support**: Tests run across Chromium, Firefox, and WebKit
## π Getting Started
### Prerequisites
- **Node.js**: v18 or higher
- **npm**: v8 or higher
### Installation
1. Clone the repository:
```bash
git clone https://github.com/AnuAknow/playwright.git
cd playwright- Install dependencies:
npm installThis will install:
@playwright/test(v1.50.1) - Playwright testing framework@types/node(v22.13.1) - TypeScript definitions for Node.js
playwright/
βββ practice/
β βββ tests/
β βββ example.spec.ts # Basic Playwright examples
βββ tests-examples/
β βββ demo-todo-app.spec.ts # Comprehensive TodoMVC app tests
βββ playwright.config.ts # Playwright configuration
βββ package.json # Project dependencies
βββ package-lock.json # Locked dependency versions
βββ .gitignore # Git ignore rules
βββ playwright.code-workspace # VS Code workspace settings
Basic example tests demonstrating core Playwright functionality:
- Page navigation and title verification
- Link interaction and heading validation
Comprehensive test suite for a TodoMVC application with extensive coverage:
- New Todo: Adding and managing todo items
- Mark all as completed: Bulk operations on todos
- Item Management: Individual item interaction and state management
- Editing: Edit, save, trim, and delete functionality
- Counter: Item count tracking
- Clear Completed: Removing completed items
- Persistence: LocalStorage data persistence across sessions
- Routing: Navigation between views (All, Active, Completed)
Key testing patterns include:
- Element locators (placeholder, role, testId)
- State assertions and class verification
- LocalStorage validation
- User interaction simulation
- Multi-step test scenarios with
test.step()
Configures test execution with:
- Test Directory:
./practice/tests - Parallel Execution: Enabled for faster test runs
- Reporters: HTML report generation
- Browsers: Chromium, Firefox, and WebKit
- Tracing: Enabled on first retry for debugging
- CI/CD Support: Configurable for CI environments
npx playwright testnpx playwright test practice/tests/example.spec.tsnpx playwright test --project=chromium
npx playwright test --project=firefox
npx playwright test --project=webkitnpx playwright test --uinpx playwright test --debugnpx playwright show-report- Role-based:
page.getByRole('button', { name: 'Clear completed' }) - Placeholder:
page.getByPlaceholder('What needs to be done?') - Test ID:
page.getByTestId('todo-item') - Text:
page.getByText('3 items left')
- Visibility:
toBeVisible(),toBeHidden() - Content:
toHaveText(),toContainText(),toHaveTitle() - State:
toBeChecked(),toBeEmpty(),toHaveClass() - Count:
toHaveCount()
- Navigation:
page.goto(),page.goBack() - Click:
.click(),.check(),.uncheck() - Input:
.fill(),.press() - Advanced:
.dblclick(),.dispatchEvent()
The TodoMVC test suite includes utility functions:
// Create multiple todo items
async function createDefaultTodos(page: Page)
// Verify todo count in LocalStorage
async function checkNumberOfTodosInLocalStorage(page: Page, expected: number)
// Verify completed todo count in LocalStorage
async function checkNumberOfCompletedTodosInLocalStorage(page: Page, expected: number)
// Verify specific todo exists in LocalStorage
async function checkTodosInLocalStorage(page: Page, title: string)The configuration supports CI/CD pipelines with:
forbidOnly: Prevents test.only from reaching CIretries: 2 retries in CI, 0 in local developmentworkers: 1 worker in CI for stability, unlimited locallytrace: Automatic trace collection for failed tests
| Package | Version | Purpose |
|---|---|---|
| @playwright/test | ^1.50.1 | Testing framework |
| @types/node | ^22.13.1 | TypeScript type definitions |
- Use specific locators: Prefer role-based or test ID locators over brittle selectors
- Wait for elements: Use Playwright's built-in waiting instead of hardcoded delays
- Organize tests: Group related tests using
test.describe() - Setup/Teardown: Use
beforeEachandafterEachhooks for test isolation - Helper functions: Extract common operations into reusable functions
- Assertions first: Verify one thing per assertion for clear failure messages
ISC
AnuAknow
Last Updated: April 7, 2026
Now let me create this README in your repository:I've created a comprehensive README.md for your AnuAknow/playwright repository. Here's what I included:
**README Structure:**
1. **Project Overview** - Introduction to the Playwright test suite with links to official documentation
2. **Quick Start** - Installation and setup instructions including:
- Prerequisites (Node.js 18+)
- Dependency installation
- Playwright browser installation
3. **Project Structure** - Breakdown of the repository organization:
- Test directories and their purposes
- Configuration files
- Helper utilities
4. **Configuration** - Details about `playwright.config.ts`:
- Test directory settings
- Parallel execution
- Retry logic for CI environments
- Browser projects (Chromium, Firefox, WebKit)
- HTML reporting
5. **Running Tests** - Commands for:
- Running all tests
- Running specific test files
- Running tests in headed mode
- Running tests in UI mode
- Debugging with Inspector
6. **Test Files Overview**:
- **example.spec.ts** - Basic Playwright patterns
- **demo-todo-app.spec.ts** - Advanced patterns including test organization, hooks, state verification, and localStorage testing
7. **Helper Functions** - Documentation of utility functions from demo-todo-app.spec.ts:
- `createDefaultTodos()` - Creates test data
- `checkNumberOfTodosInLocalStorage()` - Validates localStorage state
- `checkNumberOfCompletedTodosInLocalStorage()` - Checks completion status
- `checkTodosInLocalStorage()` - Verifies specific items
8. **Best Practices** - Guidelines for writing maintainable tests
9. **Dependencies** - Listed dev dependencies with versions
The README provides a complete guide for developers to understand and work with your Playwright testing suite.