@qamadness/qam-cypress-reporter
v0.2.0
Published
Helper that submits Cypress (Mochawesome) test results to a QAM Hub instance.
Maintainers
Readme
@qamadness/qam-cypress-reporter
Submits Cypress test results (Mochawesome JSON) to a QAM Hub instance.
Cypress has no native "after all" reporter hook, so this package exposes two ways to push results:
- A programmatic
submitToQAM()helper you can call inside anafter:runhook incypress.config.js(fully automatic — no extra npm script). - A
qam-submit-cypressCLI you run aftercypress runin your CI script.
Install
npm i -D @qamadness/qam-cypress-reporter cypress-mochawesome-reporter mochawesomeEnable Mochawesome
cypress/support/e2e.js:
import 'cypress-mochawesome-reporter/register';cypress.config.js:
const { defineConfig } = require('cypress');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
reportDir: 'cypress/reports',
overwrite: false,
html: false,
json: true,
saveJson: true,
embeddedScreenshots: true,
inlineAssets: true,
},
e2e: {
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
return config;
},
},
});Option A — automatic (after:run hook)
const { submitToQAM } = require('@qamadness/qam-cypress-reporter');
module.exports = defineConfig({
// ...reporter options above...
e2e: {
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
on('after:run', async () => {
await submitToQAM({
apiUrl: process.env.QAM_API_URL,
projectId: process.env.QAM_PROJECT_ID,
runName: `CI Run ${process.env.CI_BUILD_NUMBER ?? new Date().toISOString().slice(0, 16).replace('T', ' ')}`,
// apiToken ← process.env.QAM_API_TOKEN by default
});
});
return config;
},
},
});Then just run npx cypress run — results submit automatically.
Option B — CLI after cypress run
{
"scripts": {
"cy:run": "cypress run",
"cy:submit": "qam-submit-cypress",
"cy:test": "npm run cy:run && npm run cy:submit"
}
}The CLI reads QAM_API_URL, QAM_PROJECT_ID, QAM_API_TOKEN from env (or
accepts --api-url, --project-id, --run-name, --reports-dir,
--report-path flags). CI metadata is auto-detected (see below); override it
with --branch, --commit-sha, --commit-message, --ci-build-url,
--environment, --triggered-by (or the matching QAM_BRANCH,
QAM_COMMIT_SHA, QAM_COMMIT_MESSAGE, QAM_CI_BUILD_URL, QAM_ENVIRONMENT,
QAM_TRIGGERED_BY env vars), and disable it with --no-auto-detect-ci.
Linking to manual cases
Prefix test titles with TC-<number>:
it('TC-17: adds item to cart', () => { /* ... */ });Options (submitToQAM)
| Option | Type | Required | Default |
| ------------ | -------- | -------- | -------------------------------- |
| apiUrl | string | yes | — |
| projectId | string | yes | — |
| apiToken | string | no | process.env.QAM_API_TOKEN |
| runName | string | no | ISO timestamp |
| reportsDir | string | no | cypress/reports (latest .json) |
| reportPath | string | no | explicit JSON path (overrides dir) |
| autoDetectCiMeta | boolean | no | true (auto-detect CI/git metadata) |
| branch / commitSha / commitMessage / ciBuildUrl / environment / triggeredBy | string | no | auto — each overrides detection |
CI run metadata
By default both the helper and the CLI auto-detect the branch, commit SHA,
commit message, CI build URL, environment and triggering actor and show them on
each run in QAM Hub. It recognizes GitHub Actions, GitLab CI, CircleCI, Azure
Pipelines, Bitbucket Pipelines, Travis CI, Drone, Buildkite, Jenkins and
TeamCity, and falls back to local git for anything a provider doesn't expose.
Override any field explicitly, or set autoDetectCiMeta: false to disable it.
Learn more
- Test management for Cypress — why and how to connect Cypress to QAM Hub.
- Uploading Cypress reports — step-by-step setup guide.
- QAM Hub — the test management platform.
License
MIT
