Skip to content

πŸš€ Universal K6 load testing framework for APIs, websites, SPAs, and mobile backends. Built for comprehensive SQA testing with TypeScript.

License

Notifications You must be signed in to change notification settings

devxhub/sqa-load-test

Repository files navigation

SQA Load Test - Universal K6 Framework

A comprehensive Software Quality Assurance load testing framework built with K6 and TypeScript. Test any website, API, SPA, or mobile backend with zero configuration.

GitHub GitHub stars GitHub issues K6 TypeScript Node.js

✨ Features

  • πŸš€ Universal Testing - Test APIs, websites, SPAs, mobile backends, and GraphQL endpoints
  • ⚑ Zero Configuration - Works out of the box with sensible defaults
  • πŸ”§ Highly Configurable - Extensive customization options for advanced users
  • 🎯 Multiple Test Types - Smoke, load, stress, and spike testing
  • πŸ” Authentication Support - JWT, API keys, basic auth, and bearer tokens
  • πŸ“Š Rich Reporting - HTML and JSON reports with detailed metrics
  • 🎨 TypeScript - Full type safety and IntelliSense support
  • πŸ”„ Adaptive Thresholds - Smart thresholds based on test type and target
  • 🌐 Environment Variables - Easy configuration via environment variables

πŸš€ Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/your-username/k6-universal-load-test.git
cd k6-universal-load-test

# Install dependencies and build
pnpm install
pnpm run setup

Basic Usage

# Test any API
pnpm run quick:httpbin

# Test any website
TARGET_URL=https://example.com pnpm run test:website

# Test with authentication
TARGET_URL=https://api.example.com AUTH_TOKEN=your-token pnpm run test:api

πŸ“‹ Available Commands

Quick Tests (Pre-configured)

pnpm run quick:github   # Test GitHub API
pnpm run quick:httpbin  # Test HTTPBin API
pnpm run quick:example  # Test Example.com website

Test by Target Type

pnpm run test:api       # Test API endpoints
pnpm run test:website   # Test websites/web pages
pnpm run test:spa       # Test Single Page Applications
pnpm run test:mobile    # Test mobile app backends

Test by Load Type

pnpm run test:smoke     # Quick smoke test (1 VU, 30s)
pnpm run test:load      # Standard load test
pnpm run test:stress    # Stress test (high load)
pnpm run test:spike     # Spike test (sudden load increase)

Custom Testing

# Basic custom test
k6 run -e TARGET_URL=https://api.example.com dist/index.js

# Advanced custom test
k6 run -e TARGET_URL=https://api.example.com \
       -e TARGET_TYPE=api \
       -e TEST_TYPE=stress \
       -e AUTH_TOKEN=your-token \
       -e K6_VUS=50 \
       -e K6_DURATION=10m \
       dist/index.js

πŸ”§ Configuration

Environment Variables

Variable Description Default Options
TARGET_URL Target URL to test https://httpbin.org/get Any valid URL
TARGET_TYPE Type of target api api, website, spa, mobile-app
TEST_TYPE Type of load test load smoke, load, stress, spike
AUTH_TOKEN Authentication token - JWT, API key, etc.
K6_VUS Number of virtual users From config Any positive integer
K6_DURATION Test duration From config 30s, 5m, 1h, etc.
K6_ITERATIONS_PER_VU Iterations per VU From config Any positive integer
STRICT_THRESHOLDS Use strict thresholds false true, false

Test Profiles

The framework automatically selects appropriate configurations based on your target:

Profile VUs Duration Use Case
Smoke 1 30s Quick health checks
Light 5 2m Development testing
Moderate 10 5m Standard load testing
Heavy 50 10m Production load testing
Stress 100 15m Stress testing
Spike 200 5m Spike testing

πŸ“Š Reports

After each test, comprehensive reports are generated in the reports/ folder:

  • HTML Report: reports/latest-report.html - Visual dashboard with charts and metrics
  • JSON Summary: reports/enhanced-summary-*.json - Detailed test metadata and results
  • Quick Access: reports/index.html - Auto-redirects to the latest report

Open reports/index.html in your browser to view results.

🎯 Real-World Examples

E-commerce API Testing

k6 run -e TARGET_URL=https://api.shop.com \
       -e TARGET_TYPE=api \
       -e TEST_TYPE=load \
       -e AUTH_TOKEN=your-api-key \
       dist/index.js

News Website Performance

k6 run -e TARGET_URL=https://news.example.com \
       -e TARGET_TYPE=website \
       -e TEST_TYPE=stress \
       dist/index.js

Mobile App Backend

k6 run -e TARGET_URL=https://mobile-api.example.com \
       -e TARGET_TYPE=mobile-app \
       -e AUTH_TOKEN=bearer-token \
       dist/index.js

GraphQL API

k6 run -e TARGET_URL=https://api.example.com/graphql \
       -e TARGET_TYPE=api \
       -e TEST_TYPE=load \
       dist/index.js

πŸ” Authentication

The framework supports multiple authentication methods:

JWT/Bearer Token

k6 run -e TARGET_URL=https://api.example.com \
       -e AUTH_TOKEN=eyJhbGciOiJIUzI1NiIs... \
       dist/index.js

API Key

k6 run -e TARGET_URL=https://api.example.com \
       -e AUTH_TOKEN=your-api-key \
       dist/index.js

GitHub API Example

k6 run -e TARGET_URL=https://github.com/api/user \
       -e AUTH_TOKEN=ghp_your_github_token \
       dist/index.js

πŸ› οΈ Development

Building

pnpm run build        # Build the project
pnpm run dev          # Build and watch for changes

Code Quality

pnpm run lint         # Check code style
pnpm run lint:fix     # Fix code style issues
pnpm run format       # Format code with Prettier
pnpm run typecheck    # Type check TypeScript
pnpm run check        # Run all quality checks

Utilities

pnpm run clean        # Clean build and reports folders
pnpm run examples     # Run example configurations
pnpm run help         # Show detailed help

πŸ“ˆ Advanced Usage

Custom Configuration

For advanced scenarios, you can modify the configuration in src/config/test-config.ts:

import { QuickSetup } from './src/config/test-config';

// Custom API test with specific requirements
const customConfig = QuickSetup.testAPI(
  'https://api.example.com',
  ['/users', '/posts'],
  {
    concurrentVus: 25,
    requestTimeout: '20s',
    maxRetries: 5,
    useProxy: true,
  }
);

Environment-Specific Testing

# Development environment
NODE_ENV=development k6 run dist/index.js

# Staging environment
NODE_ENV=staging k6 run dist/index.js

# Production environment
NODE_ENV=production k6 run dist/index.js

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • K6 - Modern load testing tool
  • TypeScript - JavaScript with types
  • Vite - Next generation frontend tooling

πŸ“ž Support


Made with ❀️ by Devxhub Pvt. Ltd.

About

πŸš€ Universal K6 load testing framework for APIs, websites, SPAs, and mobile backends. Built for comprehensive SQA testing with TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published