Test Utilities Overview
This section documents the various test utility packages available in the wrkbelt platform to help with testing different aspects of the application.
Available Test Utility Packages
| Package | Description | Primary Use Case |
|---|---|---|
@wrkbelt/api/utils-test-api | API testing utilities | Testing backend APIs with Playwright |
@wrkbelt/ui/utils-test-ui | UI testing utilities | Testing UI components and pages with Playwright |
@wrkbelt/shared/utils-test | Shared testing utilities | Common utilities for all test types |
Getting Started with Test Utilities
To use these test utilities in your project, you'll need to install the relevant packages. Each package is designed to work with Playwright as the testing framework.
Setting Up a New Test
-
Install the required packages:
npm install @playwright/test @wrkbelt/shared/utils-test
# Plus any other specific test utilities based on your needs -
Create test files:
// example-api.spec.ts
import { test, expect } from '@playwright/test';
import { BookingAnswerCategoriesController } from '@wrkbelt/api/utils-test-api';
import { getValueByEnv, Environments } from '@wrkbelt/shared/utils-test';
test('API test example', async ({ request }) => {
const controller = new BookingAnswerCategoriesController(request);
const response = await controller.getBookingAnswerCategories('org-123');
expect(response.ok()).toBeTruthy();
}); -
Run the tests:
npx playwright test
Combining Utilities
The test utilities are designed to work together. For example, you can use:
@wrkbelt/shared/utils-testfor environment configuration@wrkbelt/api/utils-test-apifor testing API endpoints@wrkbelt/ui/utils-test-uifor testing UI components that interact with these APIs
Best Practices
- Use the appropriate utility package for the specific testing task
- Create reusable components and page objects for UI testing
- Leverage the BaseController pattern for API testing
- Use environment utilities to handle environment-specific configuration
- Add metadata to test reports in CI/CD pipelines
For more detailed information about each package, please refer to their individual documentation pages.