The Test You Ran Is Not the Test CI Runs
P

Phurpa Tsering

12/04/2026

The Test You Ran Is Not the Test CI Runs

API tests drift out of CI when the pipeline runs an export instead of the files you tested. How to run your .void files in GitHub Actions or GitLab with @voiden/runner, with no account, no export step and no cloud ID, plus the three flags people usually get wrong.

Here's how API tests end up in most pipelines.

Someone builds a collection in an API client. It works on their machine. To get it into CI, they export it to a JSON file, commit that file, and add a step that runs it with a separate CLI. Maybe that CLI needs an API key for a vendor's cloud. Maybe it needs the collection's cloud ID.

Three months later, the collection in the app has 40 new requests. The exported JSON in the repo has none of them. CI is green, and it's testing an API that no longer exists.

Nobody did anything wrong. The setup has two copies of the truth: the one you click on, and the one your pipeline runs. Sooner or later they drift apart.

When we shipped @voiden/runner in Voiden 2, the point was one rule that removes the second copy: the file you tested is the file CI runs. Your requests are plain-text .void files in your repo. The desktop app edits them, and the runner executes the same files headlessly. No export step, no account, no cloud ID.

The same .void files and the same command: exit 1 when the API is down, exit 0 when it's back.

That post said the runner can gate a pipeline. This one is the part we skipped then, the whole setup: your first run, a GitHub Actions workflow you can copy, the GitLab version, and the flags people usually get wrong.

Why API tests fall out of CI

When teams tell us why their API tests stopped running in CI, it usually comes down to three things.

1. The export goes stale. Many CLI runners don't read your workspace. They read a JSON file you exported from it. Every change in the app needs a fresh export and a commit, and nobody remembers to do it.

2. The runner is tied to an account. Some runners log in with an API key and report back to a vendor's cloud. That's convenient until your CI can't reach that cloud, or nobody remembers whose key it was.

3. What you can run depends on your plan. Run counts, data files or parallel runs can sit behind a plan limit. Then the test that blocks a bad merge depends on a billing setting.

None of this is a scandal. Vendors need to make money, and a cloud runner is a real product. But it means the most important test run you have, the one that blocks a bad merge, depends on an export, an account or a plan.

We wanted the opposite: a runner that needs your repo and Node.js, and no login.

Your first run, in under a minute

Start on your own machine. If it doesn't work in your terminal, it won't work in CI.

Install the runner. It needs Node.js 18 or later:

npm install -g @voiden/runner
voiden-runner --version

In CI you can skip the global install and use npx @voiden/runner run ... instead.

Point it at your requests. Say your repo looks like this:

api-tests/
  01-auth/
    login.void
  02-users/
    get-user.void
    update-user.void
  03-orders/
    create-order.void

Run one file, or the whole folder:

voiden-runner run api-tests/01-auth/login.void
voiden-runner run ./api-tests

A folder run picks up every .void file inside it, including subfolders. The order inside a folder depends on the filesystem, so don't rely on it: your Mac may list files alphabetically while a Linux CI machine doesn't. If one request depends on another, like a login that the rest need, pass the folders in the order you want. Paths run in the order you give them:

voiden-runner run api-tests/01-auth api-tests/02-users api-tests/03-orders

Now login always runs first, so its token is ready for everything after it.

The assertions and post-request scripts you wrote in the app run here too. The runner ships with the same core plugins as the desktop app, including scripting, assertions, faker, advanced auth and GraphQL. A test that fails on your screen fails in the terminal.

See what happened. By default you get one line per request, like ✓ REST POST https://api.example.com/login 200 OK 214ms, plus its assertions. When something fails and you need detail:

voiden-runner run ./api-tests --show-req --show-res   # what was sent and received
voiden-runner run ./api-tests --verbose               # plus script logs

Check the exit code, and don't trust the default. Your pipeline only cares about the exit code. Here's the catch that bites almost everyone: a plain voiden-runner run exits 0 when the run completes, even if requests failed. That's handy locally, where you're reading the output anyway. In CI it means a green check on a broken API.

So in CI, always add --fail-on-error (or --bail, more on the difference below). Then a failed request exits 1 and blocks the merge:

voiden-runner run ./api-tests --fail-on-error
echo $?   # 1 if anything failed

Stop your API, or point a request at a port where nothing is running, and run that. If you see 1, you're ready for CI.

The same command with the API down: the run exits 1 and the CI job fails.

API back up: same files, same command, exit 0.

The GitHub Actions workflow

Here's a complete workflow that runs your API tests on every push and pull request to main. Save it as .github/workflows/api-tests.yml:

name: API Tests

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  api-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Install @voiden/runner
        run: npm install -g @voiden/runner

      - name: Run API tests
        run: voiden-runner run api-tests/01-auth api-tests/02-users api-tests/03-orders --fail-on-error --env .env.ci --csv report.csv
        env:
          API_KEY: ${{ secrets.API_KEY }}
          BASE_URL: ${{ vars.BASE_URL }}

      - name: Upload report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: api-test-report
          path: report.csv

Four lines in there do most of the work:

  • --env .env.ci loads a committed file of non-secret settings, such as timeouts or a test tenant ID. Treat it like any other config file: reviewed in PRs, never holding a key.
  • API_KEY under env: passes the secret from GitHub's encrypted secrets into the run. The runner reads every environment variable of the job, so your requests can use it as {{API_KEY}}. It never touches the repo.
  • BASE_URL under env: comes from a repository variable and works the same way, as {{BASE_URL}}. The same .void file can hit staging on a PR and production on a nightly schedule.
  • if: always() uploads the report even when the tests fail. That's exactly when you want it.

If you need to override one value for a single run, use --env-var KEY=value. It wins over both the env file and the job's environment.

The same thing on GitLab

api-tests:
  image: node:20-alpine
  stage: test
  script:
    - npm install -g @voiden/runner
    - voiden-runner run api-tests/01-auth api-tests/02-users api-tests/03-orders --fail-on-error --env .env.ci --csv report.csv
  artifacts:
    when: always
    paths:
      - report.csv
    expire_in: 7 days

Set API_KEY (masked) and BASE_URL under Settings → CI/CD → Variables. GitLab passes them to the job as environment variables, and the runner picks them up as {{API_KEY}} and {{BASE_URL}}.

Jenkins, CircleCI and Bitbucket work the same way. If the job can run a shell command and has Node.js, it can run your .void files. The CI/CD docs include a plain bash script you can drop into any of them.

Look at what both files point at: folders in your repo. That's the whole integration. There's nothing to log in to and nothing to export first.

Three choices people get wrong

The workflow above is the easy part. These three decisions are where API test pipelines quietly go bad.

1. --bail or --fail-on-error?

Both make the job fail. They differ in what you learn from the failure.

FlagWhat it doesUse it when
--bailStops at the first failed requestLater requests depend on earlier ones, like a login that every other test needs. Running 40 more requests without a token only adds noise.
--fail-on-errorRuns every file, then exits with 1 if any failedYour tests are mostly independent. One run tells you everything that's broken, not just the first thing.

For pull requests, we recommend --fail-on-error. A PR that breaks three endpoints should say so in one run, not in three rounds of push and wait. For a deploy gate, --bail makes sense: you only need to know it's not safe.

2. Should runs remember anything?

By default the runner keeps a session. Values your scripts capture, like a token saved in a post-request script, persist across files and even across separate voiden-runner commands, as {{process.KEY}}. They're stored in your home folder, so they're shared by every project on that machine. Locally that's handy: log in once, then rerun one file while you debug.

In CI it can hide bugs, but the fix depends on how your tests are built:

  • Tests that chain (login in 01-auth, everything else reuses the token): keep the session, and run on a fresh CI machine so nothing leaks in from yesterday. Never reuse a session across separate jobs.
  • Tests that stand alone (each file fetches what it needs): add --no-session. Nothing is loaded, shared between files or saved, so a request can't pass just because another file left a value behind.

The bug to watch for is a request that passes on your machine only because of a token from an hour ago. If a teammate's clean run fails where yours passes, run voiden-runner session clear and try again.

3. Where do environments live?

The rule we follow: settings in the repo, secrets in the CI system.

  • Base URLs, tenant IDs and feature flags go in committed .env files (.env.ci, .env.staging), so a change to them shows up in a PR like any other change.
  • Keys and tokens only arrive through CI variables (or --env-var). If a .env file in your repo has a real key in it, that's a leak waiting for a public fork. (Where API secrets leak goes deeper on this.)
  • Use one folder of .void files for every environment. Change the env file, not the requests. Duplicating a request per environment is how the copies start drifting again.

What this doesn't solve (yet)

We'd rather you hear the trade-offs from us than find them in week two.

  • It still needs Node.js. That's one npm dependency in your pipeline. If your CI image has no Node, that's one more setup step.
  • It needs internet on a fresh machine. The runner reads the plugin list from GitHub and caches it for a day. A fully air-gapped CI job can't run it yet.
  • There's no hosted dashboard. Results go to the terminal, a CSV, a JSON file or an email report. If you want run history across months, you keep those reports yourself, as build artifacts or in a bucket.
  • The runner can only test what's in the repo. That's the point, but it also means a test that lives only on someone's laptop doesn't exist as far as CI is concerned. Getting a team to commit their requests is a habit, not a feature.

All of it is open source. If one of these blocks you, open an issue and tell us what your pipeline needs.

Try it

If you already have .void files, you're one workflow file away from running them on every PR:

npm install -g @voiden/runner
voiden-runner run ./api-tests --fail-on-error

New to Voiden? Download the app, save a few requests into a folder in your repo, and point the runner at it. Full flags are in the runner docs.

One question for you: when your API tests fail in CI today, who actually looks? The person who opened the PR, the backend team, or nobody until something breaks in production? Tell us in the comments. It helps us decide what the runner's report should show.

Related Posts