A comprehensive Software Quality Assurance load testing framework built with K6 and TypeScript. Test any website, API, SPA, or mobile backend with zero configuration.
- π 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
# 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
# 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
pnpm run quick:github # Test GitHub API
pnpm run quick:httpbin # Test HTTPBin API
pnpm run quick:example # Test Example.com website
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
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)
# 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
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 |
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 |
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.
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
k6 run -e TARGET_URL=https://news.example.com \
-e TARGET_TYPE=website \
-e TEST_TYPE=stress \
dist/index.js
k6 run -e TARGET_URL=https://mobile-api.example.com \
-e TARGET_TYPE=mobile-app \
-e AUTH_TOKEN=bearer-token \
dist/index.js
k6 run -e TARGET_URL=https://api.example.com/graphql \
-e TARGET_TYPE=api \
-e TEST_TYPE=load \
dist/index.js
The framework supports multiple authentication methods:
k6 run -e TARGET_URL=https://api.example.com \
-e AUTH_TOKEN=eyJhbGciOiJIUzI1NiIs... \
dist/index.js
k6 run -e TARGET_URL=https://api.example.com \
-e AUTH_TOKEN=your-api-key \
dist/index.js
k6 run -e TARGET_URL=https://github.com/api/user \
-e AUTH_TOKEN=ghp_your_github_token \
dist/index.js
pnpm run build # Build the project
pnpm run dev # Build and watch for changes
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
pnpm run clean # Clean build and reports folders
pnpm run examples # Run example configurations
pnpm run help # Show detailed help
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,
}
);
# 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
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- K6 - Modern load testing tool
- TypeScript - JavaScript with types
- Vite - Next generation frontend tooling
- π§ Email: [email protected]
- π Issues: GitHub Issues
- π Documentation: Wiki
Made with β€οΈ by Devxhub Pvt. Ltd.