Automated testing suite for the AngularNetTutorial CAT Pattern application using Playwright.
This repository contains end-to-end (E2E) tests that verify the entire AngularNetTutorial application works correctly from a user's perspective. Tests simulate real user interactions in a browserβclicking buttons, filling forms, navigating pagesβto ensure features work as expected.
Playwright is a modern browser automation tool by Microsoft that allows you to:
- Automate web browsers (Chromium, Firefox, WebKit)
- Test web applications like a real user would interact with them
- Run tests in parallel across multiple browsers
- Debug tests with time-travel and visual tools
- Integrate with CI/CD pipelines
- β Authentication Flows - Login/logout with IdentityServer (OAuth 2.0/OIDC)
- β Role-Based Access Control - Different permissions for Employee, Manager, HRAdmin
- β CRUD Operations - Create, read, update, delete employees, departments, positions
- β Dashboard Features - Charts, metrics, and data visualization
- β API Integration - Direct API endpoint testing
- β Visual Regression - Screenshot comparison to detect UI changes
- β Accessibility - ARIA compliance and keyboard navigation
- β Cross-Browser - Tests run on Chromium, Firefox, and Safari (WebKit)
Before running tests, you need:
Tests will fail if the application is not running!
You must start these three services before running any tests:
cd C:\apps\AngularNetTutotial\TokenService\Duende-IdentityServer\src\Duende.STS.Identity
dotnet runWait for: Now listening on: https://sts.skoruba.local
cd C:\apps\AngularNetTutotial\ApiResources\TalentManagement-API
dotnet runWait for: Now listening on: https://localhost:44378
cd C:\apps\AngularNetTutotial\Clients\TalentManagement-Angular-Material\talent-management
npm startWait for: Angular Live Development Server is listening on localhost:4200
Verify all services are running:
- Angular: http://localhost:4200 (should show login page)
- API: https://localhost:44378/swagger (should show Swagger UI)
- IdentityServer: https://sts.skoruba.local (should show IdentityServer page)
cd C:\apps\AngularNetTutotial\Tests\AngularNetTutorial-Playwright
npm installFirst-time setup only:
npx playwright installThis downloads Chromium, Firefox, and WebKit browsers for testing.
Make sure all services are running first! (See Prerequisites above)
# Run all tests (headless mode)
npx playwright test
# Run tests and see the browser (headed mode)
npx playwright test --headed
# Run tests with interactive UI (recommended for beginners)
npx playwright test --uiAfter tests complete:
npx playwright show-reportThis opens an HTML report showing which tests passed/failed with screenshots and videos.
# Run all tests
npx playwright test
# Run tests in headed mode (see browser actions)
npx playwright test --headed
# Run tests in UI mode (interactive debugging - RECOMMENDED)
npx playwright test --ui
# Run tests in debug mode (step-by-step debugger)
npx playwright test --debug# Run a specific test file
npx playwright test tests/auth/login.spec.ts
# Run all tests in a folder
npx playwright test tests/employee-management/
# Run tests matching a name pattern
npx playwright test -g "should login successfully"
# Run only failed tests from last run
npx playwright test --last-failed# Run in Chromium (default)
npx playwright test --project=chromium
# Run in Firefox
npx playwright test --project=firefox
# Run in Safari (WebKit)
npx playwright test --project=webkit
# Run in all browsers
npx playwright test --project=chromium --project=firefox --project=webkitPlaywright offers several powerful debugging tools:
The best way to debug tests interactively:
npx playwright test --uiFeatures:
- Watch tests run in real-time
- Time-travel debugging (go back to any step)
- Inspect DOM at each step
- View network requests
- Pick specific tests to run
- See screenshots and videos
Run tests with the Playwright Inspector:
npx playwright test --debugFeatures:
- Pause execution at each step
- Step through test line-by-line
- Inspect page elements with selector highlighter
- View console logs
- Execute Playwright commands manually
See the browser as tests run:
npx playwright test --headedGood for quickly seeing what's happening without the full debugger.
Tests automatically capture screenshots and videos on failure:
# Screenshots and videos saved to:
test-results/<test-name>/View them in the HTML report:
npx playwright show-reportRecord and replay test execution:
# Generate trace
npx playwright test --trace on
# View trace
npx playwright show-trace trace.zipFeatures:
- Complete timeline of test execution
- Network activity
- Console logs
- DOM snapshots at each step
- Screenshots
Tests are organized by feature area:
tests/
βββ auth/ # Login, logout, authentication
βββ employee-management/ # Employee CRUD operations
βββ department-management/ # Department CRUD
βββ position-management/ # Position CRUD (HRAdmin only)
βββ salary-ranges/ # Salary range management
βββ dashboard/ # Dashboard features
βββ api/ # Direct API endpoint tests
βββ workflows/ # Multi-step user workflows
βββ visual/ # Visual regression tests
βββ accessibility/ # ARIA compliance tests
βββ performance/ # Performance tests
Supporting Files:
fixtures/- Reusable test helpers (login, test data, API calls)page-objects/- Page Object Models for complex pagesconfig/- Test users, environment URLsplaywright.config.ts- Playwright configuration
The application has three test users with different permission levels:
| Role | Username | Password | Permissions |
|---|---|---|---|
| Employee | antoinette16 |
Pa$$word123 |
Read-only - Can view data only |
| Manager | rosamond33 |
Pa$$word123 |
Create/Update - Can create and edit employees & departments (cannot delete) |
| HRAdmin | ashtyn1 |
Pa$$word123 |
Full Access - Complete CRUD on all entities including positions and salary ranges |
Note: These credentials are defined in config/test-users.json and match the users configured in IdentityServer.
Key settings:
- Base URL:
http://localhost:4200 - Timeout: 30 seconds per test
- Retries: 2 retries on CI, 0 locally
- Browsers: Chromium, Firefox, WebKit
- Screenshots: Captured on failure
- Videos: Recorded on first retry
- Reporters: HTML, JSON, JUnit
{
"development": {
"angularUrl": "http://localhost:4200",
"apiUrl": "https://localhost:44378",
"identityServerUrl": "https://sts.skoruba.local"
}
}Problem: net::ERR_CONNECTION_REFUSED or timeout errors
Solution:
- Verify all three services are running (Angular, API, IdentityServer)
- Check URLs are accessible:
Problem: Tests fail with Test timeout of 30000ms exceeded
Solution: Increase timeout in playwright.config.ts or for specific tests:
// In your test file
test.setTimeout(60000); // 60 secondsProblem: Authentication tests fail
Possible causes:
- IdentityServer not running
- Wrong test credentials
- Browser cookies/storage interfering
Solution:
- Restart IdentityServer
- Verify test users exist in IdentityServer
- Run tests in UI mode to see what's happening:
npx playwright test --ui
Problem: Element not found or Selector not found
Solution:
- Use UI mode to inspect the page:
npx playwright test --ui - Check if element has loaded: add
await page.waitForSelector('selector') - Verify the selector is correct using Playwright Inspector
Problem: Tests work on your machine but fail in GitHub Actions
Possible causes:
- Timing issues (CI is slower)
- Browser differences
- Environment variables
Solution:
- Increase timeouts for CI
- Add explicit waits for elements
- Check CI logs for specific errors
npx playwright show-reportShows:
- β Passed/Failed tests
- β±οΈ Test duration
- π· Screenshots on failure
- π₯ Videos of test execution
- π Error messages and stack traces
npx playwright testShows real-time test progress with pass/fail indicators.
Tests run automatically on GitHub Actions when you push code. Results appear in the Actions tab.
- AngularNetTutorial - Main tutorial repository
- Angular Client - Frontend application
- .NET API - Backend API
- IdentityServer - Authentication service
- Choose the appropriate test folder (e.g.,
tests/employee-management/) - Create a new
.spec.tsfile - Follow existing test patterns
- Use fixtures for common operations (login, test data)
- Run tests locally before committing
- Keep tests independent - Each test should work in isolation
- Use descriptive names -
test('should allow Manager to create employee', ...) - Use Page Object Models - For complex pages, create POM in
page-objects/ - Use fixtures - Reuse login, data creation helpers from
fixtures/ - Clean up test data - Delete created records in
afterEach - Avoid hard-coded waits - Use
waitForSelector()instead ofwaitForTimeout()
Questions?
- Check Playwright Documentation
- Review existing tests for examples
- Open an issue in the repository
This project is part of the AngularNetTutorial repository. See parent repository for license information.
Last Updated: March 3, 2026 Playwright Version: Latest Node.js Required: 20+