A ready-to-use framework template for the practice assignments of the Playwright API Testing Mastery program by Bondar Academy.
Everything is already configured — you only need to add your credentials to the .env file and start working on the practice assignments.
Tests run against the PetClinic REST API:
- API base URL:
https://petclinic-api.bondaracademy.com/petclinic/api - Swagger documentation: petclinic-api.bondaracademy.com/petclinic/swagger-ui
Use the Swagger page to explore the available endpoints, request/response payloads and status codes while working on the assignments.
- Clone this repository and open it in your editor.
- Install the project dependencies:
npm install
- Create a
.envfile in the root of the project. Use.env-SAMPLEas an example. - Update the
.envfile with your valid Bondar Academy credentials:USERNAME='test@test.com' PASSWORD='Welcome1' - Run the sample test to make sure everything works:
npx playwright test
Note: the
.envfile is listed in.gitignore, so it is never version controlled. Your credentials stay on your local machine and are not shared or exposed in the repository.
# run all tests
npx playwright test
# run a single test file
npx playwright test tests/practiceTest.spec.ts
# run tests matching a title
npx playwright test -g 'Sample PetClinic Test'
# open the HTML report of the last run
npx playwright show-report├── tests/ # your practice assignment tests
│ └── practiceTest.spec.ts
├── utils/
│ ├── fixtures.ts # custom test fixtures (api, config, authToken)
│ ├── request-handler.ts # fluent API request builder
│ ├── custom-exptect.ts # custom assertions with API activity logs
│ ├── schema-validator.ts # AJV based JSON schema validation
│ └── logger.ts # request/response logger
├── helpers/
│ └── createToken.ts # authentication token generation
├── response-schemas/ # generated JSON schemas
├── api-test.config.ts # API URL and credentials configuration
└── playwright.config.ts # Playwright configuration
Import the test from the project fixtures and the expect from the custom expect,
then use the api fixture to build requests. The auth token is created once per worker
and attached to every request automatically.
import { test } from '../utils/fixtures';
import { expect } from '../utils/custom-exptect';
test('Sample PetClinic Test', async ({ api }) => {
const ownersResponse = await api
.path('/owners')
.getRequest(200)
expect(ownersResponse[0].firstName).toEqual('George')
})Learn more about the program: Playwright API Testing Mastery