npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

testrail-cli

v0.2.1

Published

Command line tool for reporting junit results to testrail.

Downloads

185

Readme

TestRail CLI

A simple command line tool to report test runs to TestRail from a build server.

Installation and usage

To install testrail-cli, ensure you have node installed, then run npm install -g testrail-cli

To run commands, change directories to the root of your working project (where you will likely have a .testrail-cli.yml file--see details below), and run a command like this:

testrail-cli init --runName="Name of my test run"

Full configuration and command details below.

Configuration

This CLI provides configuration in two places: environment variables (for all configs related to TestRail authentication), and a .testrail-cli.yml file, assumed to be in the working directory from which the CLI is run. Details for each below.

Environment Variables

You must provide TestRail authentication information via environment variables. It's assumed that you are storing these securely.

TESTRAIL_URL - The URL of your TestRail instance.

export TESTRAIL_URL=https://[yourinstance].testrail.net

TESTRAIL_UN - The username/e-mail address to authenticate with

export [email protected]

TESTRAIL_PW - The password associated with the aforementioned username.

export TESTRAIL_PW=yourPasswordhere

Note that the API must be enabled for your TestRail instance.

.testrail-cli.yml

It's recommended that you also supply additional configurations in a dot-file at the root of your project. This file (.testrail-cli.yml) must contain a map of test names to TestRail case IDs, but can also be used to provide default values for other useful properties. An example is provided below:

# The ID of the default project against which to run commands.
projectId: 2

# The ID of the default test suite used for test run reporting.
suiteId: 2

# A mapping that relates testcase names to TestRail case IDs. The testcase name
# (on the left) represents the "name" attribute on the "testcase" element in
# your xUnit XML files.
caseNameToIdMap:
  "Name of Test Case 7": 7
  "Another Test Name": 8
  "Not to be confused with the class name": 14

# If you have complex test suites where a case name may be identical across
# multiple classes, an alternative mapping can be provided like so:
caseClassAndNameToIdMap:
  "Name of xUnit Class 1":
    "Name of TestCase 7": 7
    "Another Test Name": 8
  "Name of another xUnit class":
    "Another Test Name": 88
    "className::testName14": 14

Commands

A list of currently supported commands and their arguments/flags. Note that every command can take a --debug flag, which outputs verbose information to stderr.

testrail-cli init

Used to initialize a test run in a given project. On success, the command will return a runId.

Arguments

  • --projectId or -p
    • Required if no ID is provided in .testrail-cli.yml. The value should be the ID of the project for which you are beginning a test run.
  • --runName or -n
    • Required. A name representing this test run.
  • --suiteId or -s
    • Optional. The ID of the test suite to use when initializing the run. If none is supplied, then a suite containing all cases is used. This can also be supplied via .testrail-cli.yml.
  • --description or -d
    • Optional. If desired, you can pass a description of this test run.
  • --milestoneId or -m
    • Optional. If desired, you can pass the ID of a milestone to associate with this test run.

Examples

Start a test run called "Automated Run" against project with ID 5.

testrail-cli init --projectId=5 --runName="Automated Run"

Start a test run called "Another Run" where the projectId is assumed from a .testrail-cli.yml file. Stash the runId for later commands.

export TESTRAIL_RUNID=$(testrail-cli init -n "Another Run")

testrail-cli report

Used to report test results for a given test run. On success, the command will report the number of case runs successfully reported.

Note that this tool makes the assumption that you have created a map in your .testrail-cli.yml file that maps test case names (as reported in your xUnit XML) to test case IDs in TestRail. An example is highlighted in the "configuration" section above.

Arguments

  • --runId or -r
    • Required. The ID of the test run for which you wish to report test results.
  • --file or -f
    • Required. The path to a xUnit XML file (or a path to a directory containing such files).

Examples

Report a test run for a single XML file and known runId.

testrail-cli report --runId=5 --file=logs/junit.xml

Report a test run for a directory of xUnit XML files using a runId pulled from environment variables.

testrail-cli report -r $TESTRAIL_RUNID -f /path/to/xml/

testrail-cli finish

Used to close a given test run.

Arguments

  • --runId or -r
    • Required. The ID of the test run you wish to close.

Examples

Close a test run based on an ID in an environment variable.

testrail-cli finish --runId=$TESTRAIL_RUNID