2.0.0-beta.0 • Published 2 days ago

qase-javascript-commons v2.0.0-beta.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 days ago

Install

$ npm install --save qase-core-reporter

Usage

Create a new Qase JS reporter in minutes by leveraging this core reporter. Use Qase core reporter with test framework custom reporter hooks

import {
  QaseCoreReporter,
  QaseOptions,
  QaseCoreReporterOptions,
  TestResult
} from "qase-core-reporter";

const reporterOptions: QaseOptions = {
  // expected options, provided by reporter user
  apiToken: 'lknkldnfknobek'
  projectCode: 'DH'
};

const qaseCoreReporterOptions: QaseCoreReporterOptions = {
  // expected core options, provider by reporter developer
  frameworkName: 'vitest',
  reporterName: 'vitest-qase-reporter'
};

// Initialize Core reporter with expected params
const reporter = new QaseCoreReporter(reporterOptions, qaseCoreReporterOptions);

// On start hook
reporter.start();

// On test results
reporter.addTestResult(test: TestResult, status, attachments);

// On end/complete hook
reporter.end({ spawn: false }); // spawn true will finish reporting in a child process

Reporter Options

reporter(qaseOptions, qaseCoreReporterOptions) ⇒ QaseCoreReporter

ParamTypeRequiredDescription
qaseOptionsobjectyes
qaseOptions.reportbooleannoWhether or not to enable reporter
qaseOptions.apiTokenstringyesQase api key
qaseOptions.projectCodestringyesQase project ID
qaseOptions.basePathstringnoQase API base url
qaseOptions.rootSuiteTitlestringnoThe root suite that unknown test cases will be added to
qaseOptions.runIdstringnoQase run ID, if you want results to be posted to a specific run
qaseOptions.loggingbooleannoWhether or not to output Qase logs while testing and reporting
qaseOptions.runCompletebooleannoWhether or not to complete a test run when results are posted
qaseOptions.environmentIdstringnoQase environment ID
qaseOptions.runDescriptionstringnoQase run custom description
qaseOptions.runNamestringnoQase run custom name
qaseCoreReporterOptionsobjectyes
qaseCoreReporterOptions.frameworkNamestringyesTest automation framework/package name
qaseCoreReporterOptions.reporterNamestringyesCurrent qase reporter package name
qaseCoreReporterOptions.uploadAttachmentsbooleannoWether or not to upload attachments
qaseCoreReporterOptions.screenshotFolderstringnoFolder to find screenshots with Qase ID in file name
qaseCoreReporterOptions.videoFolderstringnoFolder to find videos with Qase ID in file name
qaseCoreReporterOptions.loadConfigbooleannoWhether or not to also load reporter options from qase.config.json or .qaserc

API (public methods)

MethodDescription
start()Check if reporting is enabled, check project and create run if needed
addTestResult(test, status, attachments)Parse and save test results for publishing
end({spawn: true/false})Upload attachments if needed and map to existing results, send results as BulkCreate, complete run if specified
uploadAttachments(attachments)Upload attachments based on file path and return attachment hashes for test results

Qase Reporter Environmental Variables

Qase environmental variables are first class options, which means the user can change all default/static reporter options by using these variables.

| Variable | Type | Description | | ------------------------- | --------- | -------------------------------------------------------------- | | QASE_REPORT | boolean | Whether or not to enable reporter | | QASE_API_TOKEN | string | Qase api key | | QASE_API_BASE_URL | string | Qase API base url | | QASE_PROJECT_CODE | string | Qase project ID | | QASE_RUN_ID | string | Qase run ID, if you want results to be posted to a specific run | | QASE_RUN_NAME | string | Qase run custom name | | QASE_RUN_DESCRIPTION | string | Qase run custom description | | QASE_RUN_COMPLETE | string | Whether or not to complete a test run when results are posted | | QASE_ENVIRONMENT_ID | string | Qase environment ID | | QASE_ROOT_SUITE_TITLE | string | The root suite that unknown test cases will be added to | | QASE_UPLOAD_ATTACHMENTS | string | Whether or not to upload attachments | QASE_LOGGING | boolean | Whether or not to output Qase logs while testing and reporting |