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