Property specifying the version of the schema. Available versions:
2
You can define custom variables to use them later in a request. They work across files, so you can define them in one file and use them in an other.
# Example
variables:
example_url: https://jsonplaceholder.typicode.com/todos/1
example_id: 1
requests:
test:
request:
url: <$ example_url $>
...
Boolean to allow:
- insecure certificates
- self-signed certificates
- expired certificates
# Example
allowInsecure: true
someRequest:
request:
url: ...
method: ...
Array which holds all the requests that are going to be tested
# Example
requests:
request1:
..
request2:
..
request1000:
..
A single request. You can name the request however you want. Try not to overwrite names because this will also overwrite the response data and you'll no longer be able to retrieve the data from the overwritten request.
# Example
requests:
someRequestName: # <- a Request
..
This provides conditional execution of a request.
version: 2
requests:
if_Set:
request:
url: https://jsonplaceholder.typicode.com/posts
method: POST
postData:
mimeType: application/json
text:
foo: 1
skipped:
if:
operand: <$ if_Set.content.foo $>
equals: 2
request:
url: https://jsonplaceholder.typicode.com/todos/2
method: GET
executed:
if:
operand: <$ if_Set.content.foo $>
equals: 1
request:
url: https://jsonplaceholder.typicode.com/todos/2
method: GET
If present, the execution of the request will be delayed by the specified number of milliseconds.
# Example
someRequest:
delay: 2000 # Wait 2 seconds before perfoming request
request:
url: ...
method: ...
The request object conforms with HAR
The target URL to which the request will be sent to. Needs to start with http
or https
# Basic Example
someRequestName:
url: http://localhost:3000/api
# Example with a connected value
someConnectedRequest:
url: http://localhost:3000/api/user/Value(getUser.id)/friends
The HTTP request method that will be used Strest to perform the request. All strings are accepted but consider to use one of the requests listed in the Mozilla Developer Docs
# Example
somePostRequest:
request:
url: ...
method: POST
Follows this schema.
Set the mimeType to:
- application/json
- plain/text
# JSON Example
version: 2
requests:
postRequest:
request:
url: https://postman-echo.com/post
method: POST
postData:
mimeType: application/json # Set the mimeType
text:
foo:
bar: "baz"
# Raw Data Example
version: 2
requests:
postRequest:
request:
url: https://postman-echo.com/post
method: POST
postData:
mimeType: text/plain # Set the mimeType
text: "This is raw text"
Conforms to this shema. Formatted as an Array.
version: 2
requests:
responseHeaders:
request:
url: https://postman-echo.com/response-headers
method: GET
queryString:
- name: foo1
value: bar1
- name: foo2
value: bar2
Specify HTTP headers that you want to be sent with the request. Formatted as an Array.
# Basic Example
version: 2
requests:
requestHeaders:
request:
url: https://postman-echo.com/headers
method: GET
headers:
- name: exampleHeader
value: "Lorem ipsum dolor sit amet"
validate:
- jsonpath: content.headers.exampleheader
expect: "Lorem ipsum dolor sit amet"
requestHeaders2:
request:
url: https://postman-echo.com/headers
method: GET
headers:
[{ "name": "h1", "value": "v1" }, { "name": "h2", "value": "v2" }]
validate:
- jsonpath: content.headers.h1
expect: "v1"
- jsonpath: content.headers.h2
expect: "v2"
Predefined authentication methods which will set the Authorization
header automatically
HTTP Basic Authentication. Requires username and password.
# Example
someRequest:
request:
...
auth:
basic:
username: myusername
password: test123
The immediate response is stored in HAR Format
With Strest you can validate responses with:
- expect (exact match)
- regex
- type List of all valid Types
Read jsonpath for more info and see this file for more complex example
Read jsonpath for more info and see this file for more complex example
requests:
example:
...
validate:
- jsonpath: content
expect: "the response has to match this string exactly"
version: 2
requests:
typeValidate:
request:
url: https://jsonplaceholder.typicode.com/todos
method: GET
validate:
- jsonpath: headers["content-type"]
type: [ string ]
- jsonpath: status
type: [ boolean, string, number ]
- jsonpath: content.0.userId
type: [ number ]
Regex can be used to validate status code or any other returned param
version: 2
requests:
codeValidate:
request:
url: https://jsonplaceholder.typicode.com/todos
method: GET
validate: # Multiple ways to use regex to validate status code
- jsonpath: status
regex: 2\d+
- jsonpath: status
regex: 2[0-9]{2}
- jsonpath: status
regex: 2..
- jsonpath: status
regex: 2.*
Read jsonpath for more info and see this file for more complex example
If set to true
, the following information will be logged into the console for this request. HAR
- Response Status
- Response Text
- Response Headers
- Response Content
If you want to log information of all requests into the console, use the -p
flag when using the strest
command