Nikasa, home Request an invite
DocsSend requests

Send requests

What a compare can see depends on what drives your app. Start from what you already have, and you never write what the answers should be.

On this page

Nikasa sees only what your requests make the app do. This page covers the ways to send requests, and you never write what the answers should be.

Ways to drive your app #

Take the first that fits. You can add the others later.

Way What you do What you see
Drafted for you Read what nk try wrote from your app's OpenAPI or Swagger description Responses and every call behind them, by request, plus everything in the last row
Record your tests Run your Playwright, Cypress, Postman, Bruno or other suite once The same, with no request files to write
Request files Write a few .hurl files in nk/specs The same
No requests Nothing Only the start of each build and its idle time: migrations and schema, calls at startup, logs, files changed, outside calls

A service that takes its work some other way, such as gRPC or a queue, has its own page.

Requests drafted for you #

When your app serves an OpenAPI or Swagger description and you have neither nk/specs nor nk/packs/main, a healthy nk try writes nk/specs/00-safe-reads.hurl from it.

The file follows these rules:

  • It holds one GET for each path that needs no path parameter and no required query parameter, 50 at most, each with HTTP *.
  • It never holds another method.
  • It leaves out any GET whose path, summary or operation id says logout, delete, reset, export, trigger, run or send, and lists those in its opening comment.

You may edit or delete the file. nk try will not overwrite it.

A request file #

Requests are plain text in Hurl format, a text format for HTTP requests. Keep them in nk/specs. This file orders a mug, pays, then reads the order back:

request file
# nk/specs/orders.hurl: order a mug, then pay.
POST {{host}}/orders
{"sku": "mug", "quantity": 2}
HTTP *
[Captures]
id: jsonpath "$.id"

POST {{host}}/orders/{{id}}/pay
HTTP *

GET {{host}}/orders/{{id}}
HTTP *

Three parts of that file are worth knowing:

Part What it does
{{host}} Is your app's address in the sandbox.
HTTP * Takes any answer. Nikasa compares the answers, so you do not have to say what they should be.
[Captures] Passes a value from one answer into a later request.

Each request is one scenario in the report, named by its number, method and path, such as 0002 POST /orders.

Where Nikasa looks for requests #

In this order:

  1. --specs <folder> or --pack <pack> on the command
  2. nk/specs
  3. The recording in nk/packs/main

With no requests at all #

With none of those, nk compare still runs and sends nothing, and the report's first line says no requests were made. Even then, a compare watches each build's startup and idle time. This report is made up:

output
3 changes: 1 left behind, 2 in logs; none in responses or requests (no requests were made)
learned from 8 runs: 96 values fixed, 7 varying, 12 sometimes present, 0 links
no requests were made: none in --specs, --pack, nk/specs or nk/packs/main; add some with `nk record <old-image> nk/packs/main <out-dir> --app nk/app.yaml -- <test command>`
checked 4 runs of the new build

NEW    /app/A /home/app/.cache/myapp/state.json  true
       in the run's files
NEW    /app/Applying migration `<n>_add_refunds`  true
       in the run's logs
NEW    /app/Applying migration `<n>_add_coupons`  true
       in the run's logs

Here the new build applied two migrations the old one did not, as its log shows, and added a new file. Three details help you read it:

  • In the first line of the list, /app/ is the service and A means the file was added.
  • The true at the end means only that the line or the file is there.
  • <n> stands for digits.

Try your requests once #

nk run makes a single run, keeps it as a folder, and prints the requests with their statuses:

shell
nk run myapp:old out/run

It exits 1 when a request file failed, and names the file.

In a compare, a request file that failed in some runs does not change the exit status. It is named near the top of the report, with how many old and new runs it failed in:

output
request file failed: orders.hurl in 5 of 8 old runs and 3 of 4 new runs; see each run's driver.log

Work that finishes after the response #

A change only shows if it happens while Nikasa is capturing. Work a request starts and finishes later needs time inside the run. Queued jobs, logs shipped in batches and metrics that get scraped are examples.

--pause-ms <n> waits that long after every request, the last one included.

When your requests need data to exist #

Every run starts its databases empty unless you say otherwise. Start from real data covers seeds and starting from the old build's migrated database.

Next steps #

Written for nk 0.3.14. Something wrong or unclear? Write to hello@nikasa.dev.