Qase API JavaScript Client
The `qaseio` package provides a JavaScript client for interacting directly with the Qase Test Management System (TMS) API. It offers a comprehensive set of functionalities to programmatically manage various entities within Qase, including projects, test cases, test suites, milestones, shared steps, test plans, test runs, test run results, defects, custom fields, and attachments. The current npm version is 2.4.3, though the project's monorepo includes more recently updated sub-packages like `qase-javascript-commons` (v2.6.4) and various framework-specific reporters (e.g., `qase-jest` v2.3.0). This package is primarily intended for developers who need to build custom integrations with the Qase API or create bespoke test reporters for niche testing frameworks. A key differentiator and warning is that for common testing frameworks like Jest, Cypress, Playwright, TestCafe, or Mocha, the project strongly recommends using their dedicated, framework-specific reporter packages (e.g., `@qase-tms/qase-jest`) instead of this generic `qaseio` client, which is geared towards lower-level API interactions.
Common errors
-
Error: Request failed with status code 401
cause The Qase API token provided is missing or invalid, leading to an authentication failure.fixEnsure the `token` passed to `new QaseApi()` is a valid API token obtained from your Qase TMS account (personal API tokens page or app integrations page) and that it has the necessary permissions. Use environment variables like `process.env.QASE_API_TOKEN` to manage tokens securely. -
Cannot read properties of undefined (reading 'data')
cause This often occurs when an API call fails, and the `res` object (AxiosResponse) does not contain the expected `data` property, or the `res.data` itself is not the expected structure.fixWrap API calls in `try...catch` blocks. Inspect the `error.response` object in the catch block to get details like status code and error messages from the API (`error.response.data`). This helps in debugging unexpected API responses. -
TypeError: ProjectCreate is not a constructor
cause Attempting to use `ProjectCreate` (or similar models) without importing it from the correct subpath.fixEnsure you are importing models from the specific `qaseio.models` subpath: `import { ProjectCreate } from 'qaseio.models';`
Warnings
- deprecated The `qaseio` package itself is explicitly marked as deprecated within the Qase JavaScript monorepo (e.g., in `qase-javascript-commons-v2.6.2` changelog). Users should consider migrating to specific reporter packages or newer API clients if available.
- gotcha For integrating with common testing frameworks (e.g., Jest, Cypress, Playwright, Mocha), Qase recommends using their dedicated framework-specific reporter packages (e.g., `@qase-tms/qase-jest`, `@qase-tms/qase-cypress`) instead of the generic `qaseio` client. This package is intended for custom integrations and specialized reporters.
- gotcha The package requires Node.js version 14 or higher. Running in older Node.js environments may lead to unexpected errors or unsupported features.
Install
-
npm install qaseio -
yarn add qaseio -
pnpm add qaseio
Imports
- QaseApi
const { QaseApi } = require('qaseio');import { QaseApi } from 'qaseio'; - ProjectCreate
import { ProjectCreate } from 'qaseio';import { ProjectCreate } from 'qaseio.models'; - QaseApi
const qaseio = require('qaseio'); const qase = new qaseio.QaseApi({ ... });
Quickstart
import { QaseApi, ProjectCreate } from 'qaseio';
const QASE_API_TOKEN = process.env.QASE_API_TOKEN ?? '';
const PROJECT_CODE = process.env.QASE_PROJECT_CODE ?? 'PRJCODE';
const qase = new QaseApi({
token: QASE_API_TOKEN,
});
async function manageQaseProjects() {
if (!QASE_API_TOKEN) {
console.error('QASE_API_TOKEN environment variable is not set.');
return;
}
try {
console.log('Fetching all projects...');
const allProjects = await qase.projects.getAll();
console.log('All Projects Data:', allProjects.data);
const newProjectTitle = `My New Project ${Date.now()}`;
const newProjectCode = `NPRJ${Date.now().toString().slice(-4)}`;
console.log(`Creating a new project: ${newProjectTitle} (${newProjectCode})...`);
const prj = new ProjectCreate(newProjectTitle, newProjectCode);
const createdProject = await qase.projects.create(prj);
console.log('Created Project:', createdProject.data);
console.log(`Checking if project ${newProjectCode} exists...`);
const projectExists = await qase.projects.exists(newProjectCode);
console.log(`Project ${newProjectCode} exists:`, projectExists);
} catch (error) {
console.error('An error occurred:', error.response ? error.response.data : error.message);
}
}
manageQaseProjects();