vitest-qase-reporter
v1.2.0
Published
Qase TMS Vitest Reporter
Readme
Qase TestOps Vitest Reporter
Qase Vitest Reporter enables seamless integration between your Vitest tests and Qase TestOps, providing automatic test result reporting, test case management, and comprehensive test analytics.
Features
- Link automated tests to Qase test cases by ID
- Auto-create test cases from your test code
- Report test results with rich metadata (fields, attachments, steps)
- Support for parameterized tests
- Multi-project reporting support
- Flexible configuration (file, environment variables, Vitest config)
- Network Profiler for automatic HTTP request capture
Installation
npm install --save-dev vitest-qase-reporterQuick Start
1. Create qase.config.json in your project root:
{
"mode": "testops",
"testops": {
"project": "YOUR_PROJECT_CODE",
"api": {
"token": "YOUR_API_TOKEN"
}
}
}2. Add Qase ID to your test:
import { qase } from 'vitest-qase-reporter';
import { test, expect } from 'vitest';
test(qase(1, 'Test name'), () => {
expect(true).toBe(true);
});3. Run your tests:
npx vitest runConfiguration
The reporter is configured via (in order of priority):
- vitest.config.ts (Vitest-specific, highest priority)
- Environment variables (
QASE_*) - Config file (
qase.config.json)
Vitest Configuration
Add the reporter to your vitest.config.ts:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: [
'default',
[
'vitest-qase-reporter',
{
mode: 'testops',
testops: {
api: {
token: 'api_token'
},
project: 'project_code',
},
},
],
],
},
});Minimal Configuration
| Option | Environment Variable | Description |
|--------|---------------------|-------------|
| mode | QASE_MODE | Set to testops to enable reporting |
| testops.project | QASE_TESTOPS_PROJECT | Your Qase project code |
| testops.api.token | QASE_TESTOPS_API_TOKEN | Your Qase API token |
Example qase.config.json
{
"mode": "testops",
"fallback": "report",
"testops": {
"project": "YOUR_PROJECT_CODE",
"api": {
"token": "YOUR_API_TOKEN"
},
"run": {
"title": "Vitest Automated Run"
},
"batch": {
"size": 100
}
},
"report": {
"driver": "local",
"connection": {
"local": {
"path": "./build/qase-report",
"format": "json"
}
}
}
}Full configuration reference: See qase-javascript-commons for all available options including logging, status mapping, execution plans, and more.
Usage
Link Tests with Test Cases
Associate your tests with Qase test cases using test case IDs:
Single ID:
import { qase } from 'vitest-qase-reporter';
import { test, expect } from 'vitest';
test(qase(1, 'Test name'), () => {
expect(true).toBe(true);
});Multiple IDs:
test(qase([1, 2], 'Test covering multiple cases'), () => {
expect(true).toBe(true);
});Add Metadata
Enhance your tests with additional information:
import { qase } from 'vitest-qase-reporter';
import { test, expect } from 'vitest';
test('Test with metadata', async () => {
qase.title('Custom test title');
qase.fields({
severity: 'critical',
priority: 'high',
layer: 'api',
description: 'Tests core authentication flow',
});
qase.suite('Authentication / Login');
expect(true).toBe(true);
});Ignore Tests
Exclude specific tests from Qase reporting (test still runs, but results are not sent):
test('Test not reported to Qase', () => {
qase.ignore();
expect(true).toBe(true);
});Test Result Statuses
| Vitest Result | Qase Status | |---------------|-------------| | Passed | Passed | | Failed | Failed | | Skipped | Skipped |
For more usage examples, see the Usage Guide.
Running Tests
Basic test execution:
npx vitest runWith environment variables:
QASE_MODE=testops npx vitest runWith reporter enabled via config:
npx vitest run --reporter=vitest-qase-reporterWatch mode (note: reporting happens on full run completion):
npx vitestNote: Vitest is ESM-first and uses Jest-compatible API. If you're migrating from Jest, the Qase wrapper syntax is identical.
Network Profiler
The Network Profiler automatically captures outgoing HTTP requests made during test execution and reports them as REQUEST-type steps in Qase TestOps.
Additional setup: Add the profiler setup file to your Vitest configuration:
// vitest.config.ts
export default defineConfig({
test: {
setupFiles: ['vitest-qase-reporter/setup'],
},
});Enable in qase.config.json:
{
"profilers": ["network"],
"networkProfiler": {
"skip_domains": ["analytics.example.com"],
"track_on_fail": true
}
}| Option | Description | Default |
|--------|-------------|---------|
| profilers | Array of profilers to enable. Use ["network"] for HTTP capture | [] |
| networkProfiler.skip_domains | Domains to exclude from profiling | [] |
| networkProfiler.track_on_fail | Capture response body for failed requests (status >= 400) | true |
Requests to
qase.ioare always excluded automatically.
Requirements
- Node.js >= 14
- Vitest >= 3.0.0
Documentation
| Guide | Description | |-------|-------------| | Usage Guide | Complete usage reference with all methods and options | | Attachments | Adding screenshots, logs, and files to test results | | Steps | Defining test steps for detailed reporting | | Multi-Project Support | Reporting to multiple Qase projects | | Upgrade Guide | Migration guide for breaking changes |
Examples
See the examples directory for complete working examples.
License
Apache License 2.0. See LICENSE for details.
