This directory contains the end-to-end registration tests for ParaBank automation using Playwright's fixture system.
A comprehensive E2E test covering all 6 scenarios from the test requirements:
- Scenarios 1-3: Complete registration journey (Signup → Logout → Login) in sequence
- Scenarios 4-6: Independent tests using logged-in user fixture
- Scenario 4: Open New Account
- Scenario 5: Transfer Funds
- Scenario 6: Bill Pay
Based on the original scenarios/tests.txt requirements:
-
Test Scenario 1: User Sign Up ✓
- Complete registration using a unique username
- Verify success message appears
-
Test Scenario 2: User Logout ✓
- Perform logout from the registered user
- Verify redirect to login page
-
Test Scenario 3: User Login ✓
- Login with registered credentials
- Verify successful authentication
-
Test Scenario 4: Open New Account ✓
- Open a new savings account
- Verify account creation success
-
Test Scenario 5: Transfer Funds ✓
- Transfer funds between accounts
- Verify balance updated correctly
-
Test Scenario 6: Bill Pay ✓
- Submit bill payment
- Verify payment completion
This test suite uses Playwright's custom fixtures system to provide dependency injection for page objects and test setup.
Instead of importing the standard Playwright test, we import from our custom fixtures:
import { test, expect, createTestUser, waitForLoginSuccess,
waitForLogoutSuccess, waitForRegistrationSuccess,
cleanupTestData, loggedInUser } from '../../fixtures/parabank-fixtures';The test fixture provides page objects via dependency injection:
test('Complete registration journey', async ({
homePage, // ← Automatically provided by fixture
registerPage, // ← Automatically provided by fixture
page // ← Standard Playwright page
}) => {
// No manual instantiation needed!
await homePage.goto();
await registerPage.register(testUser);
});What happens behind the scenes:
- Playwright creates a test context and page
- The fixture system instantiates
HomePageandRegisterPagewith the page - These page objects are injected into your test function
- After the test, fixtures handle cleanup automatically
For scenarios requiring a logged-in user, we extend the basic fixtures:
const testWithLoggedInUser = loggedInUser.extend({});
testWithLoggedInUser('Scenario 4: Open New Account', async ({
page,
loggedInUser // ← Fully logged in user provided by fixture
}) => {
// User is already registered AND logged in!
console.log(`User ${loggedInUser.userCredentials.username} is logged in`);
// Start testing immediately without setup
});What the loggedInUser fixture does:
- Generates unique user credentials
- Creates and registers the user
- Verifies successful registration
- Provides all credentials and page objects to your test
- Handles cleanup after the test
Fixtures also export utility functions:
createTestUser(): Generate unique user credentialswaitForRegistrationSuccess(page): Wait for registration confirmationwaitForLoginSuccess(page): Wait for login completionwaitForLogoutSuccess(page): Wait for logout completioncleanupTestData(page): Clear cookies and storage
parabank-fixtures.ts
├── test (base fixture)
│ ├── homePage: HomePage
│ ├── registerPage: RegisterPage
│ ├── aboutPage: AboutPage
│ ├── servicesPage: ServicesPage
│ ├── contactPage: ContactPage
│ ├── lookupPage: LookupPage
│ ├── errorPage: ErrorPage
│ └── billPayPage: BillPayPage
│
├── loggedInUser (extends test)
│ └── Creates registered user automatically
│
└── Helper Functions
├── createTestUser()
├── waitForRegistrationSuccess()
├── waitForLoginSuccess()
├── waitForLogoutSuccess()
└── cleanupTestData()
- Dependency Injection: Page objects are automatically provided
- No Manual Setup: No need to instantiate
new HomePage(page)in tests - Automatic Cleanup: Fixtures handle teardown automatically
- Composability: Can extend fixtures for complex scenarios
- Type Safety: Full TypeScript support with proper typing
- Isolation: Each test gets fresh fixtures, preventing test pollution
- Reusability: Share setup logic across multiple tests
# Run all registration tests
npx playwright test tests/registration
# Run with headed browser (default in config)
npx playwright test tests/registration --headed
# Run specific test by name
npx playwright test -g "Complete registration journey"
# Run with UI mode (interactive)
npx playwright test --ui
# Run with trace viewer (for debugging)
npx playwright show-trace test-results/registration-*/trace.zip- Fixtures:
../../fixtures/parabank-fixtures.ts- Custom Playwright fixtures - Page Objects:
../../pages/parabank/- ParaBank page object models - Test Data:
../../src/data/user-credentials.ts- User credential generation - Types:
../../src/types/test-data.ts- TypeScript type definitions
Each test follows the Given-When-Then pattern:
test('scenario description', async ({ homePage, registerPage, page }) => {
// Given: Setup state
await homePage.goto();
// When: Perform action
await registerPage.register(testUser);
// Then: Verify result
await expect(page.locator('text=Success')).toBeVisible();
});- beforeEach: Generate unique credentials, cleanup previous data
- Test: Execute scenario using fixtures
- afterEach: Cleanup test data, clear storage
- Fixtures: Handle page object lifecycle and teardown
- ✅ Always import
testandexpectfrom fixtures - ✅ Use fixtures for page objects instead of manual instantiation
- ✅ Use
loggedInUserfixture for tests requiring authentication - ✅ Generate unique credentials in
beforeEachto avoid conflicts - ✅ Cleanup in
afterEachto ensure test isolation - ✅ Use helper functions from fixtures for common waits
- ✅ Follow Given-When-Then pattern for clarity