strest

Set up tests for REST in seconds with YAML

Getting Started

Install Strest using yarn

yarn global add strest-cli

Or via npm

npm i -g strest-cli

To test something, you have to create a REST-API first. If you already have an API to test, you can skip this step.

We’ll be using the postman-echo test API in this tutorial.

To get started, create a file called tutorial.strest.yml (The extension needs to be .strest.yml or .strest.yaml)

version: 1                            # only version at the moment

requests:                             # all test requests will be listed here
  testRequest:                        # name the request however you want
    url: https://postman-echo.com/get  # required
    method: GET                       # required
    data:                             # valid data types: params + json or raw
      params:
        foo1: bar1
        foo2: bar2
    # log: true # uncomment this to log the response

No more configuration needed, so you’re ready to go!

To run the test, open your terminal and type

strest tutorial.strest.yml

You may also run multiple test files at the same time by pointing to the directory, where the files are stored

strest # this will recursively search for all .strest.yml files in the cwd and it's subdirectories
# or
strest someDir/

Success! If you’ve done everything correctly, you’ll get a response like this

[ Strest ] Found 1 test file(s)
[ Strest ] Schema validation: 1 of 1 file(s) passed
✔ Testing testRequest succeeded (0.457s)

Find out full article on Github.

Subscribe to the Newsletter

Get our latest news,tutorials,guides,tips & deals delivered to your inbox.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.