@gotit-qa/qa-mcp v1.0.16
Test Automation Framework
A lightweight, straightforward test automation framework using Puppeteer with video recording and detailed reporting capabilities.
Features
- š Simplified Design - Direct, functional approach without complex layers
- š HTML Reports - Detailed test execution reports through Jest
- š„ Video Recording - Records videos of test execution
- šø Screenshots - Automatically captures screenshots during test failures
- š Clean API - Simple function-based API for testing
Prerequisites
- Node.js (v14 or later)
- npm or yarn package manager
Installation
# Install dependencies
npm installProject Structure
puppeteer-workspace/
āāā src/
ā āāā helpers/ # Utility functions and test middleware
ā ā āāā testUtils.ts # Core test utilities and middleware pattern
ā āāā tests/ # Test files
ā ā āāā google-simple.test.ts # Sample Google search test
ā ā āāā todo-simple.test.ts # Sample TodoMVC test
āāā reports/ # Test reports and screenshots
ā āāā screenshots/ # Screenshots from test runs
āāā videos/ # Recorded videos
āāā jest.config.js # Jest configuration
āāā tsconfig.json # TypeScript configuration
āāā package.json # Project dependencies and scriptsCreating a New Test
Creating a test is straightforward and doesn't require complex abstractions:
import { runTest, navigateTo, clickElement, typeText, TestContext } from '../helpers/testUtils';
// Define your test
test('should perform a task', async () => {
await runTest('My Test Name', async (page) => {
// Navigate to a website
await navigateTo(page, 'https://example.com');
// Interact with page elements
await typeText(page, '.search-input', 'search term');
await clickElement(page, '.submit-button');
// Make assertions
const title = await page.title();
expect(title).toContain('Expected Text');
}, {
// Test configuration options
headless: true,
slowMo: 50,
recordVideo: true,
timeout: 30000
});
});Running Tests
# Run all tests
npx jest
# Run a specific test file
npx jest path/to/test-file.test.ts
# Clean reports and videos
npm run cleanTest Reports
After running the tests, HTML reports will be available in the reports directory. Open the test-report.html file in a browser to view detailed test results.
Video Recordings
Test execution videos are automatically saved to the videos directory. Each video is named with the test name and timestamp.
Screenshots
Screenshots are automatically captured when tests fail and saved in the reports/screenshots directory.
Advantages of This Approach
- Simplicity - Function-based approach is easier to understand and maintain
- No Complex Abstractions - Direct access to Puppeteer API without multiple layers
- Middleware Pattern - Clean way to handle test setup and teardown
- Focused Tests - Tests focus on actions and assertions, not on complex page objects
- Easier Debugging - Simpler stack traces and more direct error messages
Troubleshooting
Issue: Tests fail with timeout errors Solution: Increase the timeout value in the test options
Issue: Videos not recording Solution: Check if the
videosdirectory exists and has proper permissionsIssue: Element not found errors Solution: Use appropriate waits or increase timeouts
License
MIT