This repository contains a simple Playwright automated test framework testing Dave Haefner's project The-Internet: https://the-internet.herokuapp.com/login.
The test suite exercises the login flow and related authentication setup using Playwright.
Created a new folder:
- mkdir practicing-playwright
Installed Node:
- npm install -D @types/node
Installed Playwright:
- npm init playwright@latest
Problem with the playwright.config.ts file, May 2026:
- The "forbidOnly: !!process.env.CI" did not have "process" recognized
Initialized TypeScript creating a tsconfig.json file:
- npx tsc --init
New tsconfig.json file:
- Uncommented the "For nodejs" section
- "strict": false,
Changes of playwright.config.ts per suggestions from Butch Mayhew's Learning Playwright
- Local retries: 0 -> 1: retries: process.env.CI ? 2 : 1
- timeout: 30_000,
- globalTimeout: 10 * 60 * 1000,
- use changes:
trace: 'on',
actionTimeout: 0,
ignoreHTTPSErrors: true,
video: 'retain-on-failure',
screenshot: 'only-on-failure',
headless: true
projects: [
{
name: "setup",
testMatch: /.*\.setup.ts/,
},
{
name: 'chromium',
dependencies: ["setup"],
use: { ...devices['Desktop Chrome'], permissions: ["clipboard-read"] },
package.json
"scripts": {
"test": "npx playwright test",
"test: chromium": "npx playwright test --project chromium",
"test:smoke": "npx playwright test --grep @smoke",
"test:report": "npx playwright test && npx playwright show-report",
"test:ui": "npx playwright test --ui"
},
VS Code Extensions:
- Playwright Test for VS Code
What does a testID look like? What is the prefix? Is it '[data-test="username-textbox"]'?
baseURL: 'https://practicesoftwaretesting.com',
// baseURL: 'https://the-internet.herokuapp.com/login',
testIdAttribute: "data-test",
await page.getByTestID('username-textbox').click();
package.json- npm metadata and test scripts.playwright.config.ts- Playwright configuration.tsconfig.json- TypeScript configuration.tests/- test files.auth.setup.ts- authentication setup utilities and fixtures.login/login.spec.ts- login tests.login/login.spec.ts-snapshots/- snapshot test artifacts.
lib/- page object and helper layers.pages/- page object files.login/loginPage.ts- login page model.
playwright-report/- generated HTML report output.data/andtrace/- Playwright trace and support files.test-results/- stored test result artifacts.
-
Clone the repository:
git clone <repository-url> cd practicing-playwright
-
Install dependencies:
npm install
Run the full Playwright suite:
npm testRun tests only in Chromium:
npm run "test: chromium"Open the Playwright test report after a successful run:
npm run test:reportOpen the interactive Playwright test runner UI:
npm run test:uiThis repository tags quick smoke tests with @smoke.
npm run test:smoke- Playwright - The primary test framework and browser automation library. It powers test execution, browser contexts, screenshot capture, tracing, reporting, and support for Chromium.
- Playwright Test Runner - Enables
npx playwright testcommands, test filtering, projects, retries, and the--grep @smokesmoke test convention. - TypeScript - Provides typed test code, autocompletion, and compile-time validation for page objects and test fixtures.
- Node.js / npm - Used to install dependencies, run scripts, and manage the project lifecycle.
- Playwright configuration -
playwright.config.tscontrols browser projects, timeouts, trace capture, video, screenshot behavior, and test match rules. - Page Object Model - Encapsulates page behavior in
lib/pages/login/loginPage.ts, improving maintainability and readability of login tests. - Test artifacts -
test-results/,playwright-report/, andtrace/store generated result data, HTML reports, and diagnostic traces. - VS Code Playwright extension - Recommended for running tests, exploring test structure, and debugging from the editor.
- Snapshot testing - Used for UI-related regression verification and stored under
tests/login/login.spec.ts-snapshots/.
tests/login/login.spec.tscontains the login scenarios.lib/pages/login/loginPage.tsencapsulates login page actions.test-results/andplaywright-report/are generated by test runs and can be cleaned up as needed.