Skip to content

1. The Basics

login.jkt
id: auth
request:
method: Post
url: https://api.jikken.io/api/v1/examples/login
body: {
"username": "testuser",
"password": "password"
}
response:
status: 200
extract:
- name: token
field: auth.token

First, let’s look at a very basic test case - this test simply calls a single API endpoint and verifies that the returned HTTP status matches the expected value. It also creates a variable to be used in later tests.

Let’s go over it in detail.

Making a request

request:
method: Post
url: https://api.jikken.io/api/v1/examples/login
body: {
"username": "testuser",
"password": "password"
}

The request block specifies details about the API endpoint that we want to test. In this case, we’re calling POST https://api.jikken.io/api/v1/examples/login. We also specify a body for the request using JSON.

Validating the response

response:
status: 200
extract:
- name: token
field: auth.token

The response block is where we define any validation we want to perform on the response. Here, all we’re doing is verifying that the HTTP status code is 200.

Creating a variable

Since this is a login endpoint, we then extract the returned authentication token from the response body into a variable named “token”, so we can use it in subsequent tests.

Next, we’ll see how we can leverage this variable in another test definition.