1.0.16 • Published 9 months ago

@gotit-qa/qa-mcp v1.0.16

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

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 install

Project 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 scripts

Creating 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 clean

Test 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

  1. Simplicity - Function-based approach is easier to understand and maintain
  2. No Complex Abstractions - Direct access to Puppeteer API without multiple layers
  3. Middleware Pattern - Clean way to handle test setup and teardown
  4. Focused Tests - Tests focus on actions and assertions, not on complex page objects
  5. 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 videos directory exists and has proper permissions

  • Issue: Element not found errors Solution: Use appropriate waits or increase timeouts

License

MIT

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.10

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago