To configure Vitest such that it works with Captain, we need to:
- 🧪 Ensure vitest produces json output
npx vitest run --reporter=default --reporter=json --outputFile=./tmp/vitest.json
will produce Captain-compatible JSON output in tmp/vitest.json
.
To ensure GitHub logs continue to have test output, also include a stdout-friendly reporter (for example, --reporter=default
).
# .captain/config.yaml
test-suites:
captain-examples-vitest:
command: npx vitest run --reporter=default --reporter=json --outputFile=./tmp/vitest.json
results:
path: tmp/vitest.json
Additionally, you'll need to make sure includeTaskLocation
is set to true
in the test
section of your Vitest config:
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
includeTaskLocation: true,
},
});
- 🔐 Create an Access Token
Create an Access Token for your organization within Captain (more documentation here).
Add the new token as an action secret to your repository. Conventionally, we call this secret RWX_ACCESS_TOKEN
.
- 💌 Install the Captain CLI, and then call it when running tests
See the full documentation on test suite integration.
- uses: rwx-research/setup-captain@v1
- run: captain run captain-examples-vitest
env:
RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}
- 🎉 See your test results in Captain!
Take a look at the final workflow!