This repository contains an API Test Automation Framework built using Playwright and JavaScript to test the Restful Booker API. It includes full coverage of key REST operations such as authentication, booking creation, updates, deletions, and schema validations. The project is structured for clarity and maintainability, with reusable helpers, external JSON payloads, and integration with GitHub Actions for CI.
- Automate complete API workflows using Playwright’s
request
context - Validate HTTP methods: GET, POST, PUT, PATCH, DELETE
- Support token-based authentication and protected endpoint handling
- Use
.env
for managing secrets and environment-specific values - Ensure schema, data, and type validations using
expect().toMatchObject()
- Keep test code DRY and modular using helper functions and JSON fixtures
- Generate rich HTML and Allure reports
- Enable GitHub Actions for continuous integration
-
GET Requests
- Fetch all booking IDs
- Get booking by ID
- Filter bookings by name
-
POST Requests
- Create a new booking (using inline and external JSON)
- Assert structure and values in response
-
PUT Requests
- Update booking fully using
PUT
with auth token - Validations done using external JSON payload
- Update booking fully using
-
PATCH Requests
- Partially update a booking with selective fields
- Assert only changed fields, leave rest untouched
-
DELETE Requests
- Create and then delete a booking with token
- Assert status code and empty response
-
Token Handling
- Request and reuse authorization tokens from
/auth
for protected endpoints
- Request and reuse authorization tokens from
-
Data Reuse
- Use external
.json
files for payloads - Use utility functions to reduce duplication across tests
- Use external
-
Environment Variable Support
- Sensitive values like usernames and passwords are managed using a
.env
file for local runs - GitHub Actions uses repository secrets to inject these securely during CI runs
- Sensitive values like usernames and passwords are managed using a
-
Install dependencies
npm install
-
Run all tests
npx playwright test
-
View the HTML report
npx playwright show-report
- Framework: Playwright (JavaScript)
- Test Type: REST API Automation
- APIs Tested: Restful Booker
- Language: JavaScript (CommonJS / ESModule)
- Config: .env for local and secrets for CI
- Runner: Playwright Test Runner
- Reporting: Allure Reports and Playwright HTML
allure generate target/allure-results --clean -o allure-report
- This command will create a detailed HTML report in the
allure-report
directory.
allure serve target/allure-results
- This will start a local server and open the Allure report in your default browser.
To clear previous results:
rm -rf target/allure-results
This project uses GitHub Actions for automated test execution and manual workflow triggering.
- The GitHub Actions workflow (
.github/workflows/playwright.yml
) is configured withworkflow_dispatch
to support manual test runs. - Supports manual trigger of workflow from the GitHub Actions tab by clicking the “Run workflow” button.
- Automatic triggers on
push
andpull_request
is added for automatic workflow runs.
- Add
.env
support for base URLs and secrets - Improve error handling and add edge cases
- Add retry strategies and trace analysis for failed tests
- Refactor all CRUD logic into reusable helper modules