Quickstart Guide

Get up and running with Chekov in minutes. This guide will walk you through creating your first AI-powered test.

Prerequisites

Before you begin, make sure you have:

  • Node.js 16.x or later installed
  • A package manager (npm, yarn, or pnpm)
  • A Chekov API key

Installation

First, install the required dependencies:

1
# Using npm
2
npm install -D @playwright/test @chekov/core
3
4
# Or using yarn
5
yarn add -D @playwright/test @chekov/core
6
7
# Or using pnpm
8
pnpm add -D @playwright/test @chekov/core

Project Setup

Create a new Playwright configuration file:

1
// playwright.config.ts
2
import { defineConfig, devices } from '@playwright/test';
3
4
export default defineConfig({
5
testDir: './tests',
6
use: {
7
baseURL: 'http://localhost:3000',
8
},
9
projects: [
10
{
11
name: 'chromium',
12
use: { ...devices['Desktop Chrome'] },
13
},
14
],
15
});

Writing Your First Test

Create a new test file in the tests directory:

1
// tests/login.spec.ts
2
import { test } from '@playwright/test';
3
import { ai } from '@chekov/core';
4
5
test('login flow', async ({ page }) => {
6
// Navigate to the login page
7
await page.goto('/login');
8
9
// Use AI to interact with the page
10
await ai([
11
'Type "test@example.com" in the email field',
12
'Type "password123" in the password field',
13
'Click the Login button'
14
], { page });
15
16
// Verify successful login
17
await ai('Verify we are redirected to the dashboard', { page });
18
});

Running Tests

Run your tests using the Playwright CLI:

1
# Run all tests
2
npx playwright test
3
4
# Run a specific test file
5
npx playwright test login.spec.ts
6
7
# Run tests in UI mode
8
npx playwright test --ui

Advanced Features

Parallel Actions

Optimize test execution by running independent actions in parallel:

1
test('parallel actions', async ({ page }) => {
2
await page.goto('/dashboard');
3
4
// Run multiple verifications in parallel
5
await ai([
6
'Verify the user profile is loaded',
7
'Verify the sidebar menu is visible',
8
'Verify the notifications are present'
9
], {
10
page,
11
parallelism: 3 // Run all checks simultaneously
12
});
13
});

Custom Assertions

Combine AI actions with Playwright's built-in assertions:

1
test('custom assertions', async ({ page }) => {
2
await page.goto('/profile');
3
4
// Use AI to interact with the page
5
await ai('Click the Edit Profile button', { page });
6
7
// Mix with Playwright assertions
8
await expect(page.locator('input[name="email"]')).toBeVisible();
9
10
// Continue with AI actions
11
await ai('Update the profile picture', { page });
12
});

Best Practices

  • Use clear, descriptive instructions for AI actions
  • Group related actions for better organization
  • Leverage parallelism for independent actions
  • Include explicit verification steps

Next Steps