Welcome to the Smokex documentation

Here you can find a collection of example code goodies to create your workflows

Overview

Smokex overview

Smokex provide a quick and easy way to create and automate HTTP requests to create smoke tests. These smoke tests can be used to validate deployment of a release, uptime, etc...

Main concepts

A workflow is a YAML content that defines a set of configured requests. Those requests will be executed either manually or automatically using a cron sentence.

A workflow supports asserting data from the responses of the requests and storing information in variables for further use.

Each execution sends the requests of a workflow and asserts the response using the defined specs.

It is possible to save data from a response into variables and reuse it on other requests. This is handy if you want to call an authentication endpoint and use the session token in subsequent requests.

Help us to be better

We keep improving Smokex and this documentation so if you have any feedback, got an idea, have any problem or suggestion you can contact us by email or using this form.


Examples

HTTP requests

To make an HTTP request, just specify any valid HTTP method and a target host.

Simple request

- get:
    host: "https://smokex.io"

Headers

- get:
    host: "https://smokex.io"
    headers:
      content-type: "application/json"

Query params

- get:
    host: "https://smokex.io"
    query:
      search: "my-query-search"
      filter: "all"

Adding a request body

- post:
    host: "https://smokex.io"
    body:
      name: "Michael"
      last-name: "Jordan"
      number: 23

Request options

The following request options are available:
  • The timeout of a step to receive a response, in milliseconds. Defaults to 5000.
  • Number of request retries, in case of connection failures (timeouts, connection closed, etc...) until the timeout limit. Defaults to 0.
  • Whether follow redirections from a server response. The expectations will be made against the final response. Defaults to false.

Set a request timeout

- get:
    host: "https://smokex.io"
    options:
      timeout: 2000

Retry a failed request connection

- get:
    host: "https://smokex.io"
    options:
      retries: 5

Follow server redirections

- get:
    host: "http://smokex.io"
    options:
      follow_redirects: true

Expects

By default all request will match by default a HTTP/200 response code, but more assertions can be defined.

Status code

- post:
    host: "https://smokex.io"
    body:
      name: "Michael"
      last-name: "Jordan"
      number: 23
    expect:
      status_code: 200

Headers

- post:
    host: "https://smokex.io"
    body:
      name: "Michael"
      last-name: "Jordan"
      number: 23
    expect:
      headers:
        content-type: "application/json"

Response body as JSON

Expect the body response to be a valid JSON and contain the given structure.
- get:
    host: "https://smokex.io"
    query:
      id: 23
    expect:
      json:
        available: true
        status: "healthy"
        stats:
          points: 734
          rebounds: 458

Response body as string

Expect the body response to be a string and contain the given text.
- get:
    host: "https://smokex.io"
    query:
      id: 23
    expect:
      string: "{ \"available\": true, \"status\": \"healthy\", \"stats\": { \"points\": 723, \"rebounds\": 458 } }"

Response body HTML

Expect the body response to be a valid HTML and equal the given CSS paths and its expected text.
- get:
    host: "https://smokex.io"
    query:
      id: 23
    expect:
      html:
        - path: "a.button:nth-child(2)"
          equal: "Sign up"
        - path: "ul.is-size-7:nth-child(2) > li:nth-child(5) > a:nth-child(1)"
          equal: "Blog"

Variables

You can reuse data from a response by creating variables that can be used in further tests. To do so, define a variable name and a JSON path where retrieve the data from.

Save data from response

- post:
    host: "https://smokex.io"
    body:
      name: "Michael"
      last-name: "Jordan"
      number: 23
    save_from_response:
      - variable_name: "current_points"
        json_path: "stats.points"

  - put:
    host: "https://smokex.io/players/23"
    body:
      points: ${current_points}