@api-core/k6
v0.0.1
Published
Grafana k6 load testing engine executor for API-CORE
Maintainers
Readme
@api-core/k6
Grafana k6 load testing engine executor for API-Core. This package allows you to run type-safe, contract-first API requests inside your k6 performance scripts.
Installation
npm install @api-core/k6 @api-coreQuick Start
import http from 'k6/http';
import { createClient } from '@api-core/k6';
import { registry } from './registry'; // Your API-Core registry
export default function () {
const client = createClient({
config: {
baseURL: 'https://test-api.example.com',
},
registry,
httpModule: http, // Pass k6/http module
});
const res = client.get('comment.getComment', {
path: { id: 1 },
});
console.log(`Status: ${res.status}`);
}Features
- Type-Safe Load Testing: Leverage API-Core's contract-first design to write robust, type-safe k6 load scripts.
- Native k6 Execution: delegates requests directly to native
k6/httpfor optimal performance. - Clean Autocomplete: IntelliSense is scoped strictly to k6-specific config options (
httpModule,mockHttp).
Example
For a detailed performance script example, see examples/src/tests/k6.test.ts.
API Overview
createClient(options)
Instantiates the client. The options object accepts:
registry: The API-Core contract registry.config: Global configuration overrides (likebaseURL).httpModule: The nativek6/httpimport.mockHttp: A mock k6 HTTP module for testing.
License
MIT © Shanmuka Chandra Teja Anem
Contributing
Contributions are welcome! Please read the root contributing guidelines, open an issue, or submit a pull request.
