IDE Autocomplete (@mockarty/types)
Mockarty perfengine scripts are plain JavaScript — but you’ll be much
faster writing them in TypeScript with proper IDE autocomplete. The
@mockarty/types npm package adds typings for every function the engine
exposes, so VS Code, WebStorm, IntelliJ IDEA, Neovim (LSP) and any
TypeScript-aware editor can offer code completion, parameter hints, and
inline documentation.
What you get
-
Full k6 standard library —
k6,k6/http,k6/ws,k6/grpc,
k6/data,k6/encoding,k6/crypto,k6/metrics,k6/html,
k6/execution,k6/timers. Your script keeps the standard k6 import
paths; Mockarty automatically routes them to its own implementation. -
Mockarty extensions — additional modules under
mockarty/*:Module What it provides mockarty/httpHTTP requests ( get/post/…/batch), JSON helpersmockarty/grpcgRPC client (unary calls) mockarty/soapSOAP request helpers mockarty/wsWebSocket client mockarty/sseServer-Sent Events client mockarty/kafkaKafka producer / consumer mockarty/rabbitmqRabbitMQ publish / consume mockarty/sqlSQL query helpers mockarty/redisRedis client mockarty/mcpMCP client ( connect,listTools,callTool)mockarty/dataShared data ( SharedArray)mockarty/fakerSynthetic data generators mockarty/encodingbase64 / hex encoding mockarty/cryptoHashing / HMAC mockarty/htmlHTML parsing / selectors mockarty/corecheck(),sleep(),group()mockarty/executionVU / scenario execution context mockarty/timerssetTimeout/setIntervalmockarty/metricsCounter,Trend,Rate,Gaugemockarty/allureAllure annotations ( step,feature,severity)mockarty/dtoMockarty DTO interfaces (Mock, stores) -
Global helpers — the top-level
allurebinding is injected
automatically; standard k6 globals (__VU,__ITER) are also typed.
Installation
Online
npm i --save-dev @mockarty/types
// tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "node",
"strict": true,
"types": ["@mockarty/types"]
},
"include": ["scripts/**/*.ts"]
}
mockarty-cli init scaffolds a project skeleton (mockarty.yaml + sample
tests). Add the @mockarty/types dev-dependency and tsconfig.json above to
get autocomplete in that project.
Air-gapped
On a machine with internet access run npm pack @mockarty/types
(this produces the .tgz), transfer the file, and
install locally:
npm i --save-dev /path/to/mockarty-types-X.Y.Z.tgz
The .tgz is fully self-contained, so this works without network access.
Editor setup
VS Code
Just open the project folder. VS Code reads tsconfig.json
automatically; autocomplete starts working immediately. Press
Ctrl+Space to see suggestions, F12 to jump to a type definition.
WebStorm / IntelliJ IDEA
Open the project, mark scripts/ (or wherever your .ts files live)
as Resources Root under File → Mark Directory As. WebStorm picks
up the tsconfig.json automatically. If the autocomplete dropdown
looks empty, run File → Invalidate Caches → Invalidate and Restart.
Neovim / Helix / Vim
Install typescript-language-server:
npm i -g typescript typescript-language-server
The LSP picks up @mockarty/types from your project’s
package.json — no further configuration needed.
A first script
import * as http from "k6/http";
import { check, sleep } from "k6";
import * as faker from "mockarty/faker";
import * as Allure from "mockarty/allure";
export const options = {
scenarios: {
smoke: { executor: "constant-vus", vus: 5, duration: "30s" },
},
thresholds: {
http_req_duration: ["p(95)<500"],
http_req_failed: ["rate<0.01"],
},
};
export default function (): void {
Allure.feature("signup");
const res = http.post("https://api.example.com/signup", {
email: faker.email(),
name: faker.name(),
});
check(res, {
"status is 201": (r) => r.status === 201,
"is json": (r) => (r.headers["Content-Type"] || "").includes("json"),
});
sleep(1);
}
Save as scripts/signup.ts, then run:
mockarty-cli perf run scripts/signup.ts
The CLI transpiles TypeScript to JavaScript on the fly (relative imports
are bundled too); you don’t have to run tsc yourself.
The script’s own export const options drives the run: vus,
duration, iterations, rps, maxVUs, stages, thresholds, and
scenarios are all applied. Every scenario executor is supported
(constant-vus, ramping-vus, per-vu-iterations, shared-iterations,
constant-arrival-rate, ramping-arrival-rate), including several
scenarios at once — they run in parallel, each with its own exec
function, env overlay and startTime offset, and the report merges
their metrics with exact combined percentiles plus a per-scenario
breakdown. With a flat profile explicit CLI flags win; with multiple
scenarios the scenario profiles apply as-is. An exported
handleSummary(data) function is called after the run; every key of the
returned object is written as a file (the keys stdout / stderr print
to the terminal instead). A breached threshold makes the CLI exit with
code 99 (CI-friendly — fail the pipeline on a slow build). Add
--reporter allure to get an allure-results/ directory with
per-iteration results, attachments, the run container and
executor.json.
Updating the types
Every Mockarty release ships a matching @mockarty/types version. Bump
it the same day you bump the Mockarty CLI:
npm update @mockarty/types
Your package.json should pin a compatible range
("@mockarty/types": "^0.2.0") so minor releases pull in new helpers
automatically. Major versions are bumped only on breaking type changes.
Troubleshooting
- Autocomplete shows k6 functions but not Mockarty extras. Check
that@mockarty/typesis intsconfig.json’scompilerOptions.types
array. Also make sure your editor’s TypeScript version is 5.0+
(older versions silently ignore thetypesfield for ambient
modules). Property 'status_text' does not exist on type 'Response'. Your
@mockarty/typesis older than the engine that emitted the response —
update the package (npm update @mockarty/types).Cannot find module 'mockarty/faker'. TypeScript needs to load
@mockarty/typesfor the ambient modules to resolve. Either add it
tocompilerOptions.typesorimport "@mockarty/types"once at the
top of any of your.tsfiles.
License
@mockarty/types is published under the MIT license (same as
@types/k6 that it builds on). The Mockarty product itself is
distributed under the Mockarty Software License Agreement.