This repository contains API tests using Playwright + TypeScript. We send requests to a JSONPlaceholder API with randomized data.
-
tests: Contains test scripts.
-
utils: Utility scripts, including a logger.
-
.env: Set the API base URL.
-
playwright.config.ts: Playwright Test configuration.
- utils/logger.ts: Logger module for test logs.
- tests/users.test.ts: API tests for JSONPlaceholder, including GET and POST requests.
-
Clone the repo.
-
Install dependencies with
npm install
-
Ensure Playwright dependencies are installed. Installation command:
npm init playwright@latest
-
Ensure Prettier dependencies are installed. Installation command:
npm install --save-dev eslint-config-prettier
and thennpm install --save-dev --save-exact prettier
-
Ensure ESLint dependencies are installed. Installation command:
npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint typescript
-
Ensure Faker dependencies are installed. Installation command:
npm install --save-dev @faker-js/faker
-
Ensure Dotenv dependencies are installed. Installation command:
npm install dotenv --save
-
Run tests with
npx playwright test
or manually by clicking on green run buttons near test methods
Test reports are available in the playwright-report
directory.