This repository contains an API test automation project built with TypeScript, Playwright, and Joi for validating The Dog API.
The current test coverage focuses on:
- retrieving all breeds
- retrieving a specific breed by ID
- retrieving a previously uploaded image by image ID
- retrieving a random list of images and their URLs
- uploading an image
- displaying an uploaded image in the browser
- deleting an image
- upload → delete flow validation
- Node.js installed
- npm installed
- A valid The Dog API key
Each user should create and use their own
DOG_API_KEYfrom The Dog API instead of reusing someone else's key.
npm install
npx playwright install chromium
chromiumis required because the current Playwright projects are configured to run with Chromium.
Create a .env file in the project root.
You should generate your own API key from The Dog API and store it locally in this file.
Important: Create your own personal API key, keep it private, and do not commit it to GitHub.
- Go to:
https://account.thedogapi.com/ - Register for a new account.
- Verify the email address you used during registration.
- After email verification, sign in to your The Dog API account.
- Open your account dashboard and copy Your API Key.
- Paste that key into your local
.envfile.
Example:
DOG_API_KEY=your_api_key_here
DOG_API_ENDPOINT=https://api.thedogapi.com/v1/breedsUsed to authenticate requests to The Dog API through the x-api-key header.
Base endpoint used by the shared API setup.
Current default fallback in the code:
https://api.thedogapi.com/v1/breedsThe tests dynamically convert this base endpoint into other endpoints such as:
/v1/images/upload/v1/images/:image_id/v1/images/search?limit=20
npm run test:allnpm run test:api
npm run test:breed
npm run test:get-uploaded-image
npm run test:get-random-images
npm run test:display-uploaded-image
npm run test:upload
npm run test:delete-image
npm run test:upload-delete-204
npm run test:cinpx playwright test src/tests/getRetrieveAllBreeds_api.spec.ts
npx playwright test src/tests/getRetrieve_specific_breed.spec.ts
npx playwright test src/tests/getUploadedImageById.spec.ts
npx playwright test src/tests/getRandomImages.spec.ts
npx playwright test src/tests/displayUploadedImage.spec.ts
npx playwright test src/tests/uploadImage.spec.ts
npx playwright test src/tests/deleteImageFromSpecificBreed.spec.ts
npx playwright test src/tests/uploadThenDeleteImage.spec.tsnpx playwright show-reportnpm run test:ciA minimal GitHub Actions workflow is available at:
.github/workflows/playwright-api.yml
Configure the following in GitHub:
- GitHub Secret:
DOG_API_KEY(required) - GitHub Variable:
DOG_API_ENDPOINT(optional)
If DOG_API_ENDPOINT is not provided in GitHub, the workflow uses this default value:
https://api.thedogapi.com/v1/breeds
The workflow uploads these artifacts after every run:
playwright-report/test-results/
The current test suite was built with the following assumptions:
- The Dog API is reachable from the test environment.
- The API key used in
.envis valid. DOG_API_ENDPOINTpoints to the breeds base endpoint:https://api.thedogapi.com/v1/breeds
- Some read-only tests use stable known IDs, for example:
- breed ID
2 - uploaded image ID
5UfpQCek72
- breed ID
- The local image file used for upload flows exists in the repository at:
img/breed_profile_germansheperd.jpg
- Browser-based image display tests are executed with Playwright Chromium installed.
- Random image tests request 20 images, but the suite accepts a dynamic count as long as the API returns a non-empty list and valid URLs.
The current project has some known limitations:
-
External API dependency
The suite depends on live responses from The Dog API. If the service is unavailable or changed, tests may fail. -
Upload quota limitation
Image upload tests may be skipped or blocked if the API account reaches the monthly upload quota. -
Delete permission limitation
Deleting a publicreference_image_idfrom breed data does not succeed and typically returns403 Forbiddenbecause the image is not owned by the current API key. -
Hard-coded sample IDs
Some tests rely on fixed breed IDs and fixed uploaded image IDs. If those resources change or are removed in the external API, the tests may need updates. -
Bundled local image dependency
Upload-related tests depend on the repository image fixtureimg/breed_profile_germansheperd.jpgbeing present in the workspace. -
Live data variability
Random image endpoints return live dynamic content, so the exact returned images may differ between runs. -
Limited implementation time
The assessment time window was relatively short, so deeper API exploration and broader test implementation were limited by time.
- Response validation is implemented with Joi schemas.
- Shared API setup is handled by
setupApiCredentialsHook(). - The project uses Playwright's HTML reporter, trace capture on first retry, screenshots on failure, and video recording.
If needed, refer to API_TEST_STRATEGY.md for a short overall strategy document for this test suite.
- Do NOT commit your real
.envfile. The repository already ignores.envvia.gitignore. - Create a
.env.examplewith the keys (no secret values) and commit it. Example provided in.env.example. - Add secrets in the GitHub repository: Settings → Secrets and variables → Actions → New repository secret.
- Name:
DOG_API_KEY— Value: your real API key - Optionally add
DOG_API_ENDPOINTif you use a custom endpoint.
- Name:
If you accidentally committed .env, stop tracking it and remove it from the index locally:
git rm --cached .env
git commit -m "Stop tracking .env"
git pushTo purge .env from the repository history (optional, irreversible):
- Using
git filter-repo(recommended):
pip install git-filter-repo
git clone --mirror <repo-url>
cd repo.git
git filter-repo --path .env --invert-paths
git push --force- Or use the BFG Repo Cleaner: https://rtyley.github.io/bfg-repo-cleaner/
After purging history, inform collaborators to re-clone the repository.
This project uses GitHub Actions (.github/workflows/playwright-api.yml) to run the Playwright test suite and produce test artifacts (HTML report, test-results/, and an Allure HTML report when results exist).
Quick checklist to run CI on GitHub:
- Add your
DOG_API_KEYto the repository secrets (required):- GUI: Repository → Settings → Secrets and variables → Actions → New repository secret → Name:
DOG_API_KEY→ Value: your key. - CLI:
echo -n "your_real_api_key" | gh secret set DOG_API_KEY --repo OWNER/REPO
- GUI: Repository → Settings → Secrets and variables → Actions → New repository secret → Name:
- Push a commit to
main/masteror run the workflow manually: Actions → Playwright API Tests → Run workflow (choose branch).
What the workflow produces:
playwright-report/(Playwright HTML reporter)test-results/(raw Playwright results)allure-report/(Allure HTML, generated fromallure-resultsif present)
How to view reports after a workflow run:
- In the workflow run UI, open the step logs and look for uploads; artifacts are attached at the top-right "Artifacts" section.
- Download the
allure-report(orplaywright-report) artifact, unzip it locally and openindex.htmlin your browser to view the full HTML report.
Generate or open Allure report locally (optional):
- Ensure
allure-commandlineis installed (we added it as a devDependency). Generate from results produced by Playwright:
npm run allure:generate- Open the generated report locally:
npm run allure:openNotes and troubleshooting:
- If the workflow does not run on a pull request from a fork, that's intentional: repository secrets are not exposed to forked PRs. Use a branch in the same repo or run the workflow manually.
- If
allure-reportartifact is not present, confirm that tests producedallure-results/(the reporter configurationallure-playwrightwrites to that directory).