Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

API Testing with Playwright

A TypeScript-based API testing framework using Playwright for testing REST APIs.


📋 Prerequisites

  • Node.js (v18 or later recommended)
  • npm

🚀 Getting Started

1. Install dependencies

npm install

2. Install Playwright browsers

npx playwright install

3. Configure environment variables

This project uses a .env file to store sensitive credentials that are never committed to source control.

Create a .env file in the project root by copying the example below:

DL_USERNAME=your_username
DL_PASSWORD=your_password

⚠️ Important: The .env file must not be committed to the repository. Make sure .env is listed in your .gitignore.


🧪 Running Tests

npm test

To run a specific test file:

npx playwright test tests/delivery/auth.spec.ts

To open the HTML report after a run:

npx playwright show-report

🔧 Other Scripts

Script Description
npm test Run all Playwright tests
npm run lint Lint test files with ESLint
npm run prettier:check Check formatting with Prettier
npm run prettier:format Auto-format test files with Prettier

🔒 CI / Secrets Configuration

When running tests in a CI environment, do not store credentials in a .env file. Instead, configure the environment variables as CI secrets/environment variables.

GitHub Actions

The workflow file is already provided at .github/workflows/playwright.yml.

  1. Go to your repository → Settings → Secrets and variables → Actions.
  2. Click New repository secret and add each variable:
    • DL_USERNAME
    • DL_PASSWORD
  3. The workflow will automatically pick them up:
- name: Run tests
  env:
    DL_USERNAME: ${{ secrets.DL_USERNAME }}
    DL_PASSWORD: ${{ secrets.DL_PASSWORD }}
  run: npm test

📁 Project Structure

.
├── dto/                  # Data Transfer Objects (request/response models)
├── helpers/              # Reusable API helper functions
├── tests/
│   ├── delivery/         # Authenticated API tests
│   └── example-no-auth/  # Unauthenticated / simple API tests
├── .env                  # Local environment variables (⚠️ not committed)
├── playwright.config.ts  # Playwright configuration
└── package.json

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages