Попробуем запустить запустить тесты на Playwright и отладить их с помощью playwright-ai/auto-debug.
`npm install``npx playwright install chromium`npm install playwright-ai-auto-debugexport const ai_conf = {
// API ключ - установите через переменную окружения или замените на свой
api_key: process.env.API_KEY || 'your-api-key-here',
// Настройки AI сервера
ai_server: 'https://api.mistral.ai/v1/chat/completions',
model: 'mistral-tiny',
// Директории
results_dir: 'test-results/',
report_dir: 'playwright-report',
ai_responses_dir: 'ai-responses',
// Настройки обработки
max_prompt_length: 2000,
request_delay: 20000,
// Параметры потоковой обработки
stream: true,
parallel_enabled: true,
parallel_limit: 4,
// Паттерны файлов ошибок
error_file_patterns: [
'copy-prompt.txt',
'**/error-context.md',
'*-attachment.md',
'error.txt',
'test-error.md',
'*-error.txt',
'*-error.md',
'*-result.json'
],
// Сохранение AI ответов
save_ai_responses: true,
ai_responses_dir: 'test-results',
ai_responses_filename_template: 'ai-response-{timestamp}-{index}.md',
include_metadata: true,
// 🎯 Allure интеграция
allure_integration: true,
allure_results_dir: 'allure-results',
summary_report: true,
summary_report_formats: ['html', 'markdown', 'json'],
};
npx playwright-ai coverage initnpx playwright-ai validate
npx playwright-ai doctor –fixtest("always fails", async () => {
await test.step('Navigate to page', async () => {
await page.goto('https://playwright.dev');
});
await test.step('Check wrong title', async () => {
// Намеренная ошибка: проверяем неправильный заголовок
await expect(page).toHaveTitle('This should break the test');
});
});
npx playwright testnpx playwright-aiallure serve allure-results## 💡 AI Recommended Solution
It appears that there is a discrepancy between the expected title of the page and the actual title received. The expected title is "This should break the test", but the received title is "Fast and reliable end-to-end testing for modern web apps | Playwright".
messages: [
{
role: 'system',
content: 'Ты AI помощник по отладке Playwright тестов. Анализируй ошибки и предлагай конкретные решения на русском языке. Отвечай кратко и по делу.'
}
]
## 💡 AI Recommended Solution
ошибка в ассерте `toHaveTitle`. Тест проверяет, что заголовок страницы равен "This should break the test", но полученный заголовок "Fast and reliable end-to-end testing for modern web apps | Playwright".
Решение:
1. Проверьте, что текст заголовка страницы на сайте, который вы тестируете, соответствует ожидаемому значению.
2. Если текст заголовка не соответствует ожидаемому значению, проверьте, что страница, на которую переходите, корректна и содержит нужный контент.
3. Если все еще не получается, попробуйте добавить задержку перед проверкой заголовка, чтобы дать странице загрузиться полностью.
import { test, expect } from '@playwright/test';import { test, expect } from './coverage-lib/fixture.js';npm run test:coveragenpm run coverage:openparallel_enabled: true,
parallel_limit: 4,