A Testrail reporter for mocha utilising TestRail API
npm install mocha-testrail-reporter-plus#Testrail Reporter for Mocha
Pushes test results into Testrail system.
``shell`
$ npm i mocha-testrail-reporter-plus --save-dev
Run mocha with mocha-testrail-reporter-plus:
Configure the mocharc.cjs to look like this:
`"use strict";
const { createGrep, parseArgs } = require("mocha-testrail-reporter-plus/modules");
const args = parseArgs(process.argv);
const spec = "src/*/.spec.ts";
module.exports = {
extension: ["ts"],
loader: "ts-node/esm",
spec: spec,
timeout: 100000,
grep: createGrep(args),
...(args["--testrail"] && {
reporter: "mocha-testrail-reporter-plus",
reporterOptions: { includeLastCommit: true, spec: spec, ...args },
}),
};
`
* It is necessary to include --testrail in order to report
Mark your mocha test names with ID of Testrail test cases. Ensure that your case ids are well distinct from test descriptions.
`Javascript`
it("C123 C124 Authenticate with invalid user", () => {})
it("Authenticate a valid user C321", () => {})
Only passed or failed tests will be published. Skipped or pending tests will not be published resulting in a "Pending" status in testrail test run.
It is possible to use tags for positive or negative matching of tests with the --tags and --excludeTags parameters
it("C321 Authenticate a valid user -@ Smoke,Login", () => {})`
--tags Smoke,Development
--excludeTags Production,Bug
For more information about tags refer to Tags system
TESTRAIL_HOST: string domain name of your Testrail instance (e.g. for a hosted instance instance.testrail.net)
TESTRAIL_USERNAME: string user under which the test run will be created (e.g. jenkins or ci)
TESTRAIL_PASSWORD: string password or API token for user
TESTRAIL_PROJECTID: number projet number with which the tests are associated
TESTRAIL_SUITEID: number suite number with which the tests are associated
TESTRAIL_RUNNAME: string run name
Pierre Awaragi, owner of the mocha-testrail-reporter.