This project demonstrates automated browser testing using Playwright, leveraging TypeScript and the Playwright test runner. It includes example test scripts, configuration, and CI workflow integration.
- Getting Started
- Project Structure
- Running Tests
- Useful Playwright Commands
- Continuous Integration
- Examples
- Configuration
-
Install dependencies
npm install
-
Install Playwright browsers
npx playwright install --with-deps
-
Run tests
npx playwright test
tests/— Contains main test cases (example.spec.ts,locator-test.spec.ts,porfolio.spec.ts)tests-examples/— Additional sample folder for Playwright usage (demo-todo-app.spec.ts).github/workflows/playwright.yml— GitHub Actions workflow for CIplaywright.config.ts— Playwright configuration file.vscode/mcp.json— VSCode MCP server configuration
To run all tests:
npx playwright testTo run a specific test file:
npx playwright test tests/example.spec.tsTo use the Playwright UI mode:
npx playwright test --uiTo show the HTML report after running tests:
npx playwright show-reportTo run with codegen (generate Playwright code by interacting with a site):
npx playwright codegen https://target-url.com/- Run a single test case:
npx playwright test {name}.spec.ts - Code generation:
npx playwright codegen [Link]
- Show report:
npx playwright show-report
- Run in UI mode:
npx playwright test --ui
GitHub Actions workflow at .github/workflows/playwright.yml runs tests automatically on pushes and pull requests to main or master. The workflow installs dependencies, sets up Playwright browsers, runs tests, and uploads the test report as an artifact.
See:
tests/example.spec.ts— basic Playwright tests for page navigation and assertionstests/locator-test.spec.ts— locator strategies and form interactionstests/porfolio.spec.ts— porfolio testing for my repomy-porfoliotests-examples/demo-todo-app.spec.ts— comprehensive test coverage for a TodoMVC app
- Test Directory: Specified in
playwright.config.tsas./tests - Parallel Execution: Enabled by default
- Reporters: HTML report is generated after test runs
- Browsers: Chromium enabled by default; configurations for Firefox, WebKit, mobile, and branded browsers are included as comments for easy enabling
See playwright.config.ts for more details.