Your First Test

Let's write a real test that spins up an Nginx server and verifies it responds with a 200. The whole thing takes about a minute.

Create a test file

Create a file called tests/hello.spark:

name: Hello World

tests:
  - name: Nginx responds with 200
    services:
      - name: web
        image: nginx:alpine
        healthcheck:
          test: "wget -q --spider http://localhost:80/"
          retries: 30
    execution:
      executor: http
      target: http://web
      request:
        method: GET
        url: /
    assertions:
      - statusCode:
          equals: 200
What's going on here? You're defining a test suite called "Hello World" with one test. That test starts an Nginx container, sends a GET request to its root URL, and checks that the status code is 200. The name: web in the service definition becomes the hostname — that's why the target is http://web.

Run it

spark run ./tests

Spark will:

  1. Find all *.spark files in ./tests
  2. Start an Nginx container in an isolated Docker network
  3. Wait for the health check to pass (retries up to 30 times)
  4. Send GET / to the Nginx container
  5. Assert the response status code is 200
  6. Clean up all containers and networks

You should see output like this:

  ✓ Nginx responds with 200 ........... 1.2s

  1 passed (1.2s)

Generate an HTML report

spark run ./tests --html ./reports

Open reports/index.html in your browser. You'll see a dashboard with timing breakdowns, logs, and assertion results for every test. This is especially useful when you have dozens of tests running in CI.