A TypeScript-based API testing framework using Playwright for testing REST APIs.
- Node.js (v18 or later recommended)
- npm
npm installnpx playwright installThis 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.envfile must not be committed to the repository. Make sure.envis listed in your.gitignore.
npm testTo run a specific test file:
npx playwright test tests/delivery/auth.spec.tsTo open the HTML report after a run:
npx playwright show-report| 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 |
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.
The workflow file is already provided at .github/workflows/playwright.yml.
- Go to your repository β Settings β Secrets and variables β Actions.
- Click New repository secret and add each variable:
DL_USERNAMEDL_PASSWORD
- The workflow will automatically pick them up:
- name: Run tests
env:
DL_USERNAME: ${{ secrets.DL_USERNAME }}
DL_PASSWORD: ${{ secrets.DL_PASSWORD }}
run: npm test.
βββ 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