testcafe-reporter-qase
v2.6.2
Published
Qase TMS TestCafe Reporter
Readme
Qase TestOps TestCafe Reporter
Qase TestCafe Reporter enables seamless integration between your TestCafe 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)
- Browser name as a test parameter
- Network Profiler for automatic HTTP request capture
Installation
npm install --save-dev testcafe-reporter-qaseQuick 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 using metadata:
import { test } from 'testcafe';
import { qase } from 'testcafe-reporter-qase/qase';
fixture`Example Fixture`
.page`https://example.com`;
test.meta(qase.id(1).create())(
'Test with Qase ID',
async (t) => {
await t.expect(true).ok();
}
);3. Run your tests with Qase reporter:
QASE_MODE=testops npx testcafe chrome tests/ -r spec,qaseConfiguration
The reporter is configured via (in order of priority):
- Environment variables (
QASE_*) - Config file (
qase.config.json)
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": "TestCafe 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 the qase.id() method:
Single ID:
import { qase } from 'testcafe-reporter-qase/qase';
test.meta(qase.id(1).create())(
'Test with single ID',
async (t) => {
await t.expect(true).ok();
}
);Multiple IDs:
test.meta(qase.id([1, 2, 3]).create())(
'Test linked to multiple cases',
async (t) => {
await t.expect(true).ok();
}
);Add Metadata
Enhance your tests with additional information:
Custom Title:
test.meta(qase.title('Custom test title').create())(
'Test with custom title',
async (t) => {
await t.expect(true).ok();
}
);Fields:
test.meta(
qase.fields({
'severity': 'critical',
'priority': 'high',
'layer': 'e2e',
'description': 'Verifies critical user flow',
}).create()
)(
'Test with fields',
async (t) => {
await t.expect(true).ok();
}
);Combined Metadata:
test.meta(
qase.id(1)
.title('User can login successfully')
.fields({ 'severity': 'critical', 'priority': 'high' })
.parameters({ 'browser': 'chrome', 'environment': 'staging' })
.create()
)(
'Login test',
async (t) => {
await t.typeText('#email', '[email protected]');
await t.typeText('#password', 'password123');
await t.click('#login-button');
await t.expect('#dashboard').exists;
}
);Add Steps
Create detailed test steps for better reporting:
import { qase } from 'testcafe-reporter-qase/qase';
test('Test with steps', async (t) => {
await qase.step('Navigate to login page', async () => {
await t.navigateTo('https://example.com/login');
});
await qase.step('Enter credentials', async (s1) => {
await s1.step('Type email', async () => {
await t.typeText('#email', '[email protected]');
});
await s1.step('Type password', async () => {
await t.typeText('#password', 'password123');
});
});
await qase.step('Submit form', async () => {
await t.click('#login-button');
});
});Attach Files
Attach screenshots or other files to test results:
import { qase } from 'testcafe-reporter-qase/qase';
test('Test with attachments', async (t) => {
const screenshot = await t.takeScreenshot();
qase.attach({
name: 'screenshot.png',
content: screenshot,
contentType: 'image/png',
});
qase.attach({ paths: '/path/to/log.txt' });
qase.attach({ paths: ['/path/to/file1.txt', '/path/to/file2.log'] });
});Ignore Tests
Exclude specific tests from Qase reporting (test still runs):
test.meta(qase.ignore().create())(
'Test ignored in Qase',
async (t) => {
await t.expect(true).ok();
}
);Test Result Statuses
| TestCafe Result | Qase Status | |-----------------|-------------| | passed | passed | | failed | failed | | skipped | skipped |
For more usage examples, see the Usage Guide.
Running Tests
Basic Execution
# Run all tests with Qase reporter
QASE_MODE=testops npx testcafe chrome tests/ -r spec,qase
# Run specific test file
QASE_MODE=testops npx testcafe chrome tests/login.test.js -r qase
# Run in headless mode
QASE_MODE=testops npx testcafe chrome:headless tests/ -r qaseMultiple Browsers
# Run in multiple browsers
QASE_MODE=testops npx testcafe chrome,firefox tests/ -r qase
# Run in all installed browsers
QASE_MODE=testops npx testcafe all tests/ -r qaseEnvironment Variables
# Override configuration with environment variables
QASE_MODE=testops \
QASE_TESTOPS_PROJECT=DEMO \
QASE_TESTOPS_API_TOKEN=your_token \
npx testcafe chrome tests/ -r qaseWith TestCafe Configuration File
Create .testcaferc.json:
{
"browsers": ["chrome:headless"],
"src": ["tests/**/*.test.js"],
"reporter": [
{
"name": "spec"
},
{
"name": "qase"
}
],
"concurrency": 3,
"quarantineMode": false
}Then run:
QASE_MODE=testops npx testcafeBrowser as Parameter
When running tests, the reporter can automatically add the browser name as a test parameter. The browser is detected from TestCafe's user agent string (e.g., "Chrome 97.0 / macOS 10.15" → "chrome").
Enable in qase.config.json:
{
"framework": {
"testcafe": {
"browser": {
"addAsParameter": true,
"parameterName": "browser"
}
}
}
}| Option | Description | Default |
|--------|-------------|---------|
| browser.addAsParameter | Add browser name as a test parameter | false |
| browser.parameterName | Name of the parameter | browser |
Network Profiler
The Network Profiler automatically captures outgoing HTTP requests made during test execution and reports them as REQUEST-type steps in Qase TestOps.
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
- TestCafe >= 2.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 | | Configuration Reference | Full configuration options |
Examples
See the examples directory for complete working examples.
License
Apache License 2.0. See LICENSE for details.
