The `testrail-api-client` package provides a JavaScript and TypeScript binding for the TestRail API v2, enabling programmatic interaction with a TestRail instance. Currently at version 1.0.37, it sees frequent patch releases for bug fixes and dependency updates, notably for `axios`. This client differentiates itself through its explicit support for both CommonJS and ES module environments, though documentation leans towards CommonJS. It also offers convenient auto-configuration via environment variables. The library streamlines common TestRail operations such as creating and closing test runs, retrieving test cases and results, and adding results, making it suitable for integrating with automated testing workflows.
npm install testrail-api-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the TestRail client using environment variables and then perform common actions like creating a test run and adding results for specific test cases.
Ensure that if you are using custom SSL certificates, they are properly configured and trusted by the Node.js environment. Avoid ignoring SSL errors in production to maintain secure communication. The feature is likely controlled by an option in the client constructor or an environment variable, but details are not explicitly documented; consult the source for 'ignore SSL' configuration.
For explicit configuration, always use `const TestRailClient = require('testrail-api-client').default;` and then `new TestRailClient(options)`. If relying on environment variables for auto-configuration, `const client = require('testrail-api-client');` is appropriate.Always test after updating to new patch versions that modify `axios` dependencies. If experiencing unexpected HTTP errors or request failures, check the changelog for `axios` specific notes and consider pinning a specific `testrail-api-client` version if compatibility issues arise.
Ensure `TESTRAIL_DOMAIN`, `TESTRAIL_USERNAME`, and either `TESTRAIL_APIKEY` or `TESTRAIL_PASSWORD` are set as environment variables before running the application, or initialize the client explicitly with configuration options: `new TestRailClient({ domain: '...', username: '...', password: '...' });`.Double-check `TESTRAIL_DOMAIN`, `TESTRAIL_USERNAME`, and `TESTRAIL_APIKEY` (or `TESTRAIL_PASSWORD`) environment variables or the options passed to the `TestRailClient` constructor. Verify credentials in TestRail's 'My Settings' and ensure the user has API access and project permissions.
If this is a controlled environment (e.g., local development), you might allow self-signed certificates (though not recommended for production). Set the `TESTRAIL_IGNORE_SSL` environment variable to `true` (if the library supports it, otherwise check for a constructor option) or set `NODE_TLS_REJECT_UNAUTHORIZED='0'` (use with extreme caution). The best fix is to configure Node.js to trust the certificate or use a properly signed certificate.
For CommonJS, use `const TestRailClient = require('testrail-api-client').default;`. For ESM, use `import TestRailClient from 'testrail-api-client';`.Ensure `TESTRAIL_DOMAIN`, `TESTRAIL_USERNAME`, and either `TESTRAIL_APIKEY` or `TESTRAIL_PASSWORD` are set as environment variables before running the application, or initialize the client explicitly with configuration options: `new TestRailClient({ domain: '...', username: '...', password: '...' });`.