The test stage
Run tests in the test stage from the console, hart and CI.
test in harthelm.yml lists the steps that test your code. It runs like prepare: in the workspace, in
/data/app, one step after the other, and the first failing step fails the stage.
schema: harthelm/v1
prepare:
- name: Install dependencies
run: npm ci
test:
- name: Lint
run: npm run lint
- name: Unit tests
run: npm testThe test stage sees the workspace's env vars but no secrets. It reads the file as it is when it starts, so it needs no Sync.
Run it
In the Run panel's Prepare card, open More stages and click Run test stage. Each step shows its state; the output icon on a step shows its log.
Run prepare first if the tests need its results. A stage that is already running cannot start twice; stop it with
Stop or hart stop --stage test.
Read the output again
hart logs --stage test
hart logs --stage test --step 1hart logs shows the saved output; --step counts from 0.
Run it from CI
A pipeline that pushed to the workspace's branch pulls, prepares and tests, and fails when the tests fail:
set -e
hart ws wake --wait
hart git pull
hart prepare -f
hart test -fSee Use hart in CI for the sign-in and the settings.
Per profile
With profiles, each file has its own test steps. hart test -p prod runs those of
harthelm.prod.yml; without -p the selected profile's.