Skip to content

Quick reference ​

Every syntax table for Mock Studio 1.2.0 on one page. Each section links to the page that explains it.

Path syntax ​

PatternMatchesCaptured as
/usersExactly /users
/users/:idOne segment in place of :id{{params.id}}
/files/*Any single segment{{params.wildcard0}}
/a/*/b/*Two single segments{{params.wildcard0}}, {{params.wildcard1}}
/assets/**Everything after, including nothing{{params.rest}}
  • Query strings and trailing slashes are ignored when matching.
  • Fixed text is case-sensitive.
  • * and ** must be a whole segment.

More: Endpoints and paths.

Which endpoint answers ​

RuleDetail
Only enabled endpoints are considered
The method must fitThe same method, or ANY
The most specific path winsFixed segment 3 points, :name or * 1 point, ** 0 points
On a tieThe endpoint higher in the list
HEAD with no HEAD endpointThe matching GET endpoint answers, with no body
OPTIONS while CORS is onThe server answers 204 itself
Nothing fitsProxy passthrough if set, otherwise 404

Methods ​

ANY, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS

Response strategies ​

StrategySends
Single responseAlways the first response
Conditional rulesThe first response whose conditions all match; a response with no conditions is the fallback
Sequence (round-robin)Each response in turn, then starts again
Random / weightedA random response; chance = weight ÷ total of weights

More: Response strategies.

Body types ​

Body typeContent-Type
JSONapplication/json
Texttext/plain
HTMLtext/html
XMLapplication/xml
Emptynone, and no body

Status codes offered in the list: 200, 201, 204, 400, 401, 403, 404, 409, 422, 429, 500, 502, 503.

More: Responses.

Template tokens ​

Tokens work in response bodies and response header values.

TokenReplaced with
{{params.<name>}}Path parameter
{{params.wildcard0}}Segment matched by the first *
{{params.rest}}Everything matched by **
{{query.<name>}}Query-string parameter
{{header.<name>}}Request header; the name is not case-sensitive
{{body.<path>}}Field of the JSON request body, such as {{body.user.name}} or {{body.items.0.id}}
{{uuid}}Random UUID
{{now}}, {{now.iso}}Current UTC time, ISO 8601
{{timestamp}}, {{now.unix}}Current unix time in seconds
{{randomInt(a,b)}}Whole number from a to b, both included
{{randomInt}}Whole number from 0 to 999
{{faker.name}}First and last name
{{faker.firstName}}First name
{{faker.lastName}}Last name
{{faker.email}}Email address at example.com
{{faker.phone}}Phone number
{{faker.city}}City
{{faker.company}}Company name
{{faker.word}}Single word
{{faker.color}}Hex colour
{{faker.bool}}true or false
{{faker.uuid}}Same as {{uuid}}

A token that is unknown, or has no value in the request, is left in the response as typed.

More: Dynamic templating.

Rule sources ​

SourceKey
Query paramParameter name
HeaderHeader name; not case-sensitive
Path paramParameter name without the colon; wildcard0, rest
Body field (JSON path)Dotted path, such as user.role
HTTP methodNot used; the value is the method in capitals

Rule operators ​

OperatorMatches when
equalsThe value is exactly the same; case-sensitive
does not equalThe value is different, or missing
containsYour text appears anywhere in the value
existsThe value is present and not empty
matches regexThe regular expression matches anywhere in the value
greater thanBoth are numbers and the value is larger
less thanBoth are numbers and the value is smaller

All conditions on a response are joined with AND. More: Conditional rules.

Delay ​

text
delay = (Delay override, if set, otherwise Base delay)
      + Global delay
      + random 0 to Random jitter
SettingWhere
Global delay (ms)Project
Base delay (ms)Endpoint, Advanced settings
Random jitter (ms)Endpoint, Advanced settings
Delay override (ms)Response card

Faults ​

FaultThe client sees
No faultThe normal response
Drop connectionA connection error, no status code
Empty responseThe status code with an empty body and no Content-Type
Malformed bodyThe status code with invalid JSON labelled as JSON
Hang (never respond)Nothing for 2 minutes, then the normal response

More: Latency and faults.

Replies the server makes itself ​

SituationStatusBody
No endpoint matches404{"error":"not_found","message":"No mock endpoint matched GET /path","hint":"…"}
Required auth header is missing401{"error":"unauthorized","message":"Missing Authorization header"}
OPTIONS request while CORS is on204none
Proxy target cannot be reached502{"error":"proxy_failed","message":"…"}

CORS headers ​

Sent while Enable CORS is on:

http
access-control-allow-origin: *
access-control-allow-methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
access-control-allow-headers: *
access-control-max-age: 86400

More: Auth, CORS and project settings.

Flow syntax ​

Tokens in a step's path, headers and body ​

TokenReplaced with
{{vars.<name>}}Value extracted by an earlier step in the same iteration
{{vu}}Virtual user number, from 1
{{iteration}}Round number, from 1
{{uuid}}, {{now}}, {{timestamp}}, {{randomInt(a,b)}}, {{faker.*}}A generated value

Expect ​

ValueSuccess means
emptyAny status below 400
200Exactly 200
2xxAny status from 200 to 299
200,201,404Any listed code

Extract into variables ​

One per line, as name = source.

SourceReads
body.<path>Field of the JSON reply, such as body.token or body.items.0.id
header.<name>Response header
statusStatus code

Headers ​

One per line, as Name: value.

Load profile ​

SettingDefaultRange or note
Virtual users51 to 1000
Iterations / user10Ignored when a duration is set
Duration (s)00 = use iterations
Ramp-up (s)0Spreads user starts
Think time (ms)0Pause after each step, or each round in All at once
Step modeOne by oneOr All at once
Stop iteration on first failed stepOnOne by one only
Target base URLemptyEmpty = this project's mock

A request times out after 30 seconds. More: Flows.

Addresses ​

CallerAddress
This computerhttp://localhost:<port>
Same networkhttp://<LAN address>:<port>
Android emulatorhttp://10.0.2.2:<port>
InternetThe tunnel's https:// address

More: Share on LAN or the internet.

Limits ​

WhatLimit
Requests kept in the Live log500 per project, in memory
Body length shown in the Live logAbout 64,000 characters
Recorded proxy replies held200, with 20 shown at a time
Virtual users in a flow1000
Throughput chartLast 2 minutes
Default port of a new project8080, or the next free number

Files ​

WhatWhere
ProjectsDocuments/MockStudio/projects, one .json file per project
Exported projectWherever you save it; suggested name ends in .mockstudio.json

More: Projects, files and Git.

Keyboard shortcuts ​

Mock Studio 1.2.0 has no app-specific keyboard shortcuts.

Next steps ​