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
| Pattern | Matches | Captured as |
|---|---|---|
/users | Exactly /users | |
/users/:id | One 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
| Rule | Detail |
|---|---|
| Only enabled endpoints are considered | |
| The method must fit | The same method, or ANY |
| The most specific path wins | Fixed segment 3 points, :name or * 1 point, ** 0 points |
| On a tie | The endpoint higher in the list |
HEAD with no HEAD endpoint | The matching GET endpoint answers, with no body |
OPTIONS while CORS is on | The server answers 204 itself |
| Nothing fits | Proxy passthrough if set, otherwise 404 |
Methods
ANY, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Response strategies
| Strategy | Sends |
|---|---|
| Single response | Always the first response |
| Conditional rules | The 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 / weighted | A random response; chance = weight ÷ total of weights |
More: Response strategies.
Body types
| Body type | Content-Type |
|---|---|
| JSON | application/json |
| Text | text/plain |
| HTML | text/html |
| XML | application/xml |
| Empty | none, 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.
| Token | Replaced 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
| Source | Key |
|---|---|
| Query param | Parameter name |
| Header | Header name; not case-sensitive |
| Path param | Parameter name without the colon; wildcard0, rest |
| Body field (JSON path) | Dotted path, such as user.role |
| HTTP method | Not used; the value is the method in capitals |
Rule operators
| Operator | Matches when |
|---|---|
| equals | The value is exactly the same; case-sensitive |
| does not equal | The value is different, or missing |
| contains | Your text appears anywhere in the value |
| exists | The value is present and not empty |
| matches regex | The regular expression matches anywhere in the value |
| greater than | Both are numbers and the value is larger |
| less than | Both are numbers and the value is smaller |
All conditions on a response are joined with AND. More: Conditional rules.
Delay
delay = (Delay override, if set, otherwise Base delay)
+ Global delay
+ random 0 to Random jitter| Setting | Where |
|---|---|
| Global delay (ms) | Project |
| Base delay (ms) | Endpoint, Advanced settings |
| Random jitter (ms) | Endpoint, Advanced settings |
| Delay override (ms) | Response card |
Faults
| Fault | The client sees |
|---|---|
| No fault | The normal response |
| Drop connection | A connection error, no status code |
| Empty response | The status code with an empty body and no Content-Type |
| Malformed body | The 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
| Situation | Status | Body |
|---|---|---|
| No endpoint matches | 404 | {"error":"not_found","message":"No mock endpoint matched GET /path","hint":"…"} |
| Required auth header is missing | 401 | {"error":"unauthorized","message":"Missing Authorization header"} |
OPTIONS request while CORS is on | 204 | none |
| Proxy target cannot be reached | 502 | {"error":"proxy_failed","message":"…"} |
CORS headers
Sent while Enable CORS is on:
access-control-allow-origin: *
access-control-allow-methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
access-control-allow-headers: *
access-control-max-age: 86400More: Auth, CORS and project settings.
Flow syntax
Tokens in a step's path, headers and body
| Token | Replaced 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
| Value | Success means |
|---|---|
| empty | Any status below 400 |
200 | Exactly 200 |
2xx | Any status from 200 to 299 |
200,201,404 | Any listed code |
Extract into variables
One per line, as name = source.
| Source | Reads |
|---|---|
body.<path> | Field of the JSON reply, such as body.token or body.items.0.id |
header.<name> | Response header |
status | Status code |
Headers
One per line, as Name: value.
Load profile
| Setting | Default | Range or note |
|---|---|---|
| Virtual users | 5 | 1 to 1000 |
| Iterations / user | 10 | Ignored when a duration is set |
| Duration (s) | 0 | 0 = use iterations |
| Ramp-up (s) | 0 | Spreads user starts |
| Think time (ms) | 0 | Pause after each step, or each round in All at once |
| Step mode | One by one | Or All at once |
| Stop iteration on first failed step | On | One by one only |
| Target base URL | empty | Empty = this project's mock |
A request times out after 30 seconds. More: Flows.
Addresses
| Caller | Address |
|---|---|
| This computer | http://localhost:<port> |
| Same network | http://<LAN address>:<port> |
| Android emulator | http://10.0.2.2:<port> |
| Internet | The tunnel's https:// address |
More: Share on LAN or the internet.
Limits
| What | Limit |
|---|---|
| Requests kept in the Live log | 500 per project, in memory |
| Body length shown in the Live log | About 64,000 characters |
| Recorded proxy replies held | 200, with 20 shown at a time |
| Virtual users in a flow | 1000 |
| Throughput chart | Last 2 minutes |
| Default port of a new project | 8080, or the next free number |
Files
| What | Where |
|---|---|
| Projects | Documents/MockStudio/projects, one .json file per project |
| Exported project | Wherever 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.