Installation
Get started with Chekov by following these simple installation steps.
Prerequisites
- Node.js 16.x or later
- npm, yarn, or pnpm package manager
- Playwright Test installed in your project
Installing Chekov
You can install Chekov using your preferred package manager:
Using npm
1npm install -D @chekov/core
Using yarn
1yarn add -D @chekov/core
Using pnpm
1pnpm add -D @chekov/core
Project Setup
After installing Chekov, you'll need to configure your Playwright test files to use it. Here's a basic setup:
1// playwright.config.ts2import { defineConfig, devices } from '@playwright/test';34export default defineConfig({5testDir: './tests',6use: {7baseURL: 'http://localhost:3000',8},9projects: [10{11name: 'chromium',12use: { ...devices['Desktop Chrome'] },13},14],15});
Create your first test file:
1// tests/example.spec.ts2import { test } from '@playwright/test';3import { ai } from '@chekov/core';45test('my first test', async ({ page }) => {6await page.goto('/');7await ai('Click the login button', { page });8await ai('Type "test@example.com" in the email field', { page });9});
Configuration Options
Chekov can be configured with various options to customize its behavior:
1// chekov.config.ts2import { defineConfig } from '@chekov/core';34export default defineConfig({5// Maximum time to wait for an action to complete6timeout: 5000,78// Number of retry attempts for failed actions9retries: 3,1011// Custom error messages12errorMessages: {13elementNotFound: 'Could not find the specified element',14actionFailed: 'The requested action could not be completed',15},1617// Logging options18logging: {19level: 'info',20silent: false,21},22});
Environment Setup
For optimal performance, consider setting these environment variables:
1# .env2CHEKOV_API_KEY=your_api_key_here3CHEKOV_TIMEOUT=50004CHEKOV_RETRY_COUNT=3
Important Notes
- Always keep your API key secure and never commit it to version control
- Consider using different timeouts for development and CI environments
- Adjust retry counts based on your application's stability
