Hunt Getting started Docs GitLab Hub

Getting started

This path builds the hunt CLI and the @slopkit/hunt SDK from the 0.1.0 tag, writes one Scenario and its Step definitions, and runs it. You need Nix with flakes, git, and Node.js 24.

The first success is a passing Scenario in your terminal. Hosted runs, Snapshots, Stubs and CI come after that.

Build the CLI and the SDK

Make a project directory and build both packages from the 0.1.0 tag into it.

mkdir shop-e2e
cd shop-e2e
nix build "git+https://gitlab.techtailors.net/slopkit/hunt?ref=0.1.0#hunt" -o hunt-bin
nix build "git+https://gitlab.techtailors.net/slopkit/hunt?ref=0.1.0#hunt-sdk" -o hunt-sdk

Each build writes a symlink to a Nix store path. Put the CLI on your PATH for this shell, then check it:

export PATH="$PWD/hunt-bin/bin:$PATH"
hunt --version

Match:

hunt 0.1.0

Each release also publishes a self-extracting hunt-linux-amd64 binary that needs no Nix, and the SDK in the project's npm registry. The repo README lists both. This page uses the source build.

Step definitions import @slopkit/hunt. Link the SDK you just built into node_modules.

mkdir -p node_modules/@slopkit features steps
ln -s "$(readlink -f hunt-sdk)/lib/node_modules/@slopkit/hunt" node_modules/@slopkit/hunt

Write a Scenario

A Feature is a user-facing capability. A Scenario is one named example of it, written as Given, When and Then Steps.

Tell Hunt where the Features and Step definitions are, and which runtime hosts the Steps.

cat > hunt.toml <<'EOF'
features = "features"
steps = ["steps/**/*.ts"]
runtime = ["node"]
EOF

Write the Scenario. The @smoke tag is a tag you can select on later.

cat > features/cart.feature <<'EOF'
Feature: Cart

  @smoke
  Scenario: Adding two items
    Given an empty cart
    When I add 2 items at 5 euros each
    Then the cart total is 10 euros
EOF

Write the Step definitions. {int} is a Cucumber Expression parameter. A Step fails when it throws.

cat > steps/cart.ts <<'EOF'
import { Given, Then, When, type Context } from "@slopkit/hunt";

const cart = (ctx: Context) => ctx.state as { total: number };

Given("an empty cart", (ctx) => {
  cart(ctx).total = 0;
});

When("I add {int} items at {int} euros each", (ctx, count: number, price: number) => {
  cart(ctx).total += count * price;
});

Then("the cart total is {int} euros", (ctx, expected: number) => {
  const { total } = cart(ctx);
  if (total !== expected) throw new Error(`expected ${expected}, got ${total}`);
});
EOF

Run it

List what Hunt found.

hunt list

The path in brackets is the absolute path to your Feature file, so yours will differ.

Feature: Cart
  Scenario: Adding two items  @smoke  [<project>/features/cart.feature:4]
    Given an empty cart
    When I add 2 items at 5 euros each
    Then the cart total is 10 euros

Run the Scenarios tagged @smoke.

hunt run --tags @smoke

Match this output. The duration will differ. The command exits 0.

✓ Cart › Adding two items  (6 ms)
    ✓ Given an empty cart
    ✓ When I add 2 items at 5 euros each
    ✓ Then the cart total is 10 euros

1 scenarios: 1 passed, 0 failed, 0 undefined, 0 ambiguous

Change 10 euros to 11 euros in the Then line of features/cart.feature, then run hunt run again. The failing Step shows its error, and the command exits 1.

✗ Cart › Adding two items  (7 ms)
    ✓ Given an empty cart
    ✓ When I add 2 items at 5 euros each
    ✗ Then the cart total is 11 euros
        expected 11, got 10

1 scenarios: 0 passed, 1 failed, 0 undefined, 0 ambiguous

Change it back to 10 euros.

Run Steps once without a Feature file. This is an Exploration, and nothing is recorded in the Baseline.

hunt explore 'Given an empty cart' 'When I add 3 items at 4 euros each'

Match:

Exploration (nothing is recorded in the Baseline)
✓ Exploration › Exploration  (12 ms)
    ✓ Given an empty cart
    ✓ When I add 3 items at 4 euros each

Check the files

shop-e2e/
├── features/cart.feature
├── hunt-bin -> /nix/store/...-hunt-0.1.0
├── hunt-sdk -> /nix/store/...-slopkit-hunt-sdk-0.1.0
├── hunt.toml
├── node_modules/@slopkit/hunt -> /nix/store/.../lib/node_modules/@slopkit/hunt
└── steps/cart.ts

Next steps

Open the docs for the commands, hunt.toml and the SDK. Source and issues are in the product repo.

Verified

Run on this machine (Linux x86-64, Nix with flakes, Node 24.22.2) in an empty scratch directory, in the order shown, with the real output above. Paths in hunt list were shortened.

Passed:

  • nix build "git+https://gitlab.techtailors.net/slopkit/hunt?ref=0.1.0#hunt" -o hunt-bin and the same for #hunt-sdk. The tag 0.1.0 exists on the public repo.
  • hunt --version, the ln -s link, the three cat > ... <<'EOF' files, hunt list, hunt run --tags @smoke (exit 0), hunt run after changing the expected total to 11 (exit 1), hunt explore. The failing run was produced with sed instead of an editor, with the same result.

Not run:

  • The release binary hunt-linux-amd64 from the package registry. The URL answered 401 Unauthorized without credentials, so the page does not give a command for it.
  • npm install @slopkit/hunt from the project npm registry (the .npmrc line in docs/ci.md). The registry also answered 401 Unauthorized.
  • Anything on Bun, Deno, the browser, Stubs, Clock Shifts, the hosted service or CI.