CLI — @qa-hub/cli
@qa-hub/cli is a framework-agnostic command-line tool for uploading test results to QA Hub from any CI/CD pipeline.
Install
npm install -g @qa-hub/cli
# or use directly via npx
npx @qa-hub/cli upload ...
Upload test results
qa-hub upload \
--token qh_abc_yoursecret \
--url https://your-qahub.com \
--project your-project-id \
--format playwright \
--run-name "CI build #442" \
playwright-results.json
Options
| Flag | Description |
|---|---|
--token | API token (write scope required) |
--url | Base URL of your QA Hub instance |
--project | Project ID to create the run under |
--format | Result format (see below) |
--run-name | Name for the test run |
--environment | Environment label (e.g., staging) |
Supported formats
| Format | File type | --format value |
|---|---|---|
| Playwright | JSON reporter output | playwright |
| Cypress | JUnit XML | cypress |
| Jest | JUnit XML | jest |
| Any JUnit-compatible | XML | junit |
Playwright example
Configure Playwright to output a JSON report:
// playwright.config.ts
export default {
reporter: [
['list'],
['json', { outputFile: 'playwright-results.json' }],
],
};
Then upload in your CI step:
# GitHub Actions
- name: Run Playwright tests
run: npx playwright test
- name: Upload results to QA Hub
if: always()
run: |
npx @qa-hub/cli upload \
--token ${{ secrets.QA_HUB_TOKEN }} \
--url ${{ secrets.QA_HUB_URL }} \
--project ${{ vars.QA_HUB_PROJECT_ID }} \
--format playwright \
--run-name "CI #${{ github.run_number }}" \
playwright-results.json
Jest + JUnit example
# Install jest-junit
npm install --save-dev jest-junit
# Run Jest with JUnit reporter
JEST_JUNIT_OUTPUT_FILE=results.xml npx jest --reporters=jest-junit
# Upload
npx @qa-hub/cli upload --format jest --run-name "Unit tests" results.xml
Map results to test cases
Tag your test titles with @qa-hub('TC-NNN') to link CI results to existing test cases in the library:
// Playwright
test("Login — invalid credentials @qa-hub('TC-042')", async ({ page }) => {
// ...
});
// Jest
it("should reject expired tokens @qa-hub('TC-017')", () => {
// ...
});
The CLI extracts the tag and sets test_case_code when posting results. Untagged tests are recorded as unlinked results and counted in metrics but not mapped to library test cases.
Environment variables
You can set defaults via environment variables to avoid repeating flags:
export QA_HUB_TOKEN=qh_abc_yoursecret
export QA_HUB_URL=https://your-qahub.com
export QA_HUB_PROJECT=your-project-id
Exit codes
| Code | Meaning |
|---|---|
0 | All results uploaded successfully |
1 | Upload failed (authentication error, network error) |
2 | Partial upload — some results rejected (see output) |