Skip to main content

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

FlagDescription
--tokenAPI token (write scope required)
--urlBase URL of your QA Hub instance
--projectProject ID to create the run under
--formatResult format (see below)
--run-nameName for the test run
--environmentEnvironment label (e.g., staging)

Supported formats

FormatFile type--format value
PlaywrightJSON reporter outputplaywright
CypressJUnit XMLcypress
JestJUnit XMLjest
Any JUnit-compatibleXMLjunit

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

CodeMeaning
0All results uploaded successfully
1Upload failed (authentication error, network error)
2Partial upload — some results rejected (see output)