vitest-qase-reporter 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/changelog.md +6 -0
- package/dist/index.d.ts +1 -15
- package/dist/index.js +12 -30
- package/dist/vitest.d.ts +9 -0
- package/dist/vitest.js +12 -2
- package/docs/MULTI_PROJECT.md +53 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -195,6 +195,12 @@ A test run will be performed and available at:
|
|
|
195
195
|
https://app.qase.io/run/QASE_PROJECT_CODE
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
+
### Multi-Project Support
|
|
199
|
+
|
|
200
|
+
Qase Vitest Reporter supports sending test results to multiple Qase projects simultaneously. You can specify different test case IDs for each project using `addQaseProjects(name, mapping)`.
|
|
201
|
+
|
|
202
|
+
For detailed information, configuration, and examples, see the [Multi-Project Support Guide](docs/MULTI_PROJECT.md).
|
|
203
|
+
|
|
198
204
|
## Configuration
|
|
199
205
|
|
|
200
206
|
Reporter options (* - required):
|
package/changelog.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -7,22 +7,8 @@ export declare class VitestQaseReporter implements Reporter {
|
|
|
7
7
|
private reporter;
|
|
8
8
|
private currentSuite;
|
|
9
9
|
private testMetadata;
|
|
10
|
-
/**
|
|
11
|
-
* @type {RegExp}
|
|
12
|
-
*/
|
|
10
|
+
/** @deprecated Use parseProjectMappingFromTitle from qase-javascript-commons for multi-project support. */
|
|
13
11
|
static qaseIdRegExp: RegExp;
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} title
|
|
16
|
-
* @returns {number[]}
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private static getCaseId;
|
|
20
|
-
/**
|
|
21
|
-
* @param {string} title
|
|
22
|
-
* @returns {string}
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
private static removeQaseIdsFromTitle;
|
|
26
12
|
constructor(options?: VitestQaseOptionsType);
|
|
27
13
|
/**
|
|
28
14
|
* Create TestResultType from Vitest TestCase
|
package/dist/index.js
CHANGED
|
@@ -6,31 +6,8 @@ class VitestQaseReporter {
|
|
|
6
6
|
reporter;
|
|
7
7
|
currentSuite = undefined;
|
|
8
8
|
testMetadata = new Map();
|
|
9
|
-
/**
|
|
10
|
-
* @type {RegExp}
|
|
11
|
-
*/
|
|
9
|
+
/** @deprecated Use parseProjectMappingFromTitle from qase-javascript-commons for multi-project support. */
|
|
12
10
|
static qaseIdRegExp = /\(Qase ID: ([\d,]+)\)/;
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} title
|
|
15
|
-
* @returns {number[]}
|
|
16
|
-
* @private
|
|
17
|
-
*/
|
|
18
|
-
static getCaseId(title) {
|
|
19
|
-
const [, ids] = title.match(VitestQaseReporter.qaseIdRegExp) ?? [];
|
|
20
|
-
return ids ? ids.split(',').map((id) => Number(id)) : [];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @param {string} title
|
|
24
|
-
* @returns {string}
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
static removeQaseIdsFromTitle(title) {
|
|
28
|
-
const matches = title.match(VitestQaseReporter.qaseIdRegExp);
|
|
29
|
-
if (matches) {
|
|
30
|
-
return title.replace(matches[0], '').trimEnd();
|
|
31
|
-
}
|
|
32
|
-
return title;
|
|
33
|
-
}
|
|
34
11
|
constructor(options = {}) {
|
|
35
12
|
const composedOptions = (0, qase_javascript_commons_1.composeOptions)(options, {});
|
|
36
13
|
this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
@@ -45,18 +22,23 @@ class VitestQaseReporter {
|
|
|
45
22
|
*/
|
|
46
23
|
createTestResult(testCase) {
|
|
47
24
|
const result = testCase.result();
|
|
48
|
-
const
|
|
25
|
+
const parsed = (0, qase_javascript_commons_1.parseProjectMappingFromTitle)(testCase.name);
|
|
49
26
|
const diagnostic = testCase.diagnostic();
|
|
50
27
|
const testId = testCase.id ?? testCase.name;
|
|
51
28
|
const metadata = this.testMetadata.get(testId);
|
|
52
|
-
// Use title from metadata if available, otherwise use
|
|
53
|
-
const testTitle = metadata?.title ??
|
|
29
|
+
// Use title from metadata if available, otherwise use cleaned name (multi-project markers stripped)
|
|
30
|
+
const testTitle = metadata?.title ?? (parsed.cleanedTitle.replace(/\s+/g, ' ').trim() || testCase.name);
|
|
54
31
|
const testResult = new qase_javascript_commons_1.TestResultType(testTitle);
|
|
55
32
|
testResult.id = testCase.id ?? '';
|
|
56
33
|
testResult.signature = testCase.fullName ?? testCase.name;
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
// Multi-project: set testops_project_mapping when any (Qase PROJECT: ids) is present
|
|
35
|
+
const hasProjectMapping = Object.keys(parsed.projectMapping).length > 0;
|
|
36
|
+
if (hasProjectMapping) {
|
|
37
|
+
testResult.testops_project_mapping = parsed.projectMapping;
|
|
38
|
+
testResult.testops_id = null;
|
|
39
|
+
}
|
|
40
|
+
else if (parsed.legacyIds.length > 0) {
|
|
41
|
+
testResult.testops_id = parsed.legacyIds.length === 1 ? parsed.legacyIds[0] : parsed.legacyIds;
|
|
60
42
|
}
|
|
61
43
|
else {
|
|
62
44
|
testResult.testops_id = null;
|
package/dist/vitest.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
type StepFunction = () => Promise<void> | void;
|
|
2
|
+
/** Project code → test case IDs for multi-project (testops_multi) mode. */
|
|
3
|
+
export type ProjectMapping = Record<string, number[]>;
|
|
2
4
|
export declare const addQaseId: (name: string, caseIds: number[]) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Build test name with multi-project markers (for testops_multi mode).
|
|
7
|
+
* @param name — test title
|
|
8
|
+
* @param mapping — e.g. { PROJ1: [1, 2], PROJ2: [3] }
|
|
9
|
+
* @example it(addQaseProjects('Login flow', { PROJ1: [100], PROJ2: [200] }), async () => { ... });
|
|
10
|
+
*/
|
|
11
|
+
export declare const addQaseProjects: (name: string, mapping: ProjectMapping) => string;
|
|
3
12
|
type AnnotateFunction = (message: string, options?: unknown) => Promise<void>;
|
|
4
13
|
export interface QaseWrapper {
|
|
5
14
|
annotate(message: string, options?: unknown): Promise<void>;
|
package/dist/vitest.js
CHANGED
|
@@ -3,14 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.withQase = exports.addQaseId = void 0;
|
|
6
|
+
exports.withQase = exports.addQaseProjects = exports.addQaseId = void 0;
|
|
7
7
|
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
// Function to add Qase ID to test name
|
|
9
|
+
// Function to add Qase ID to test name (single project)
|
|
10
10
|
const addQaseId = (name, caseIds) => {
|
|
11
11
|
return `${name} (Qase ID: ${caseIds.join(',')})`;
|
|
12
12
|
};
|
|
13
13
|
exports.addQaseId = addQaseId;
|
|
14
|
+
/**
|
|
15
|
+
* Build test name with multi-project markers (for testops_multi mode).
|
|
16
|
+
* @param name — test title
|
|
17
|
+
* @param mapping — e.g. { PROJ1: [1, 2], PROJ2: [3] }
|
|
18
|
+
* @example it(addQaseProjects('Login flow', { PROJ1: [100], PROJ2: [200] }), async () => { ... });
|
|
19
|
+
*/
|
|
20
|
+
const addQaseProjects = (name, mapping) => {
|
|
21
|
+
return (0, qase_javascript_commons_1.formatTitleWithProjectMapping)(name, mapping);
|
|
22
|
+
};
|
|
23
|
+
exports.addQaseProjects = addQaseProjects;
|
|
14
24
|
/**
|
|
15
25
|
* Create qase wrapper for annotate function
|
|
16
26
|
* @param annotate - Vitest annotate function
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Multi-Project Support in Vitest
|
|
2
|
+
|
|
3
|
+
Qase Vitest Reporter supports sending test results to multiple Qase projects simultaneously. This feature allows you to report the same test execution to different projects with different test case IDs, which is useful when:
|
|
4
|
+
|
|
5
|
+
* You need to report the same test to different projects
|
|
6
|
+
* Different projects track the same functionality with different test case IDs
|
|
7
|
+
* You want to maintain separate test runs for different environments or teams
|
|
8
|
+
|
|
9
|
+
## Configuration
|
|
10
|
+
|
|
11
|
+
For detailed configuration options, refer to the [qase-javascript-commons README](../../qase-javascript-commons/README.md#multi-project-support).
|
|
12
|
+
|
|
13
|
+
### Basic Multi-Project Configuration
|
|
14
|
+
|
|
15
|
+
Set `mode` to `testops_multi` in your Vitest config (e.g. in `vitest.config.ts` or `qase.config.json`) and add the `testops_multi` section with `default_project` and `projects`.
|
|
16
|
+
|
|
17
|
+
## Using `addQaseProjects(name, mapping)`
|
|
18
|
+
|
|
19
|
+
Use the `addQaseProjects(name, mapping)` helper from `vitest-qase-reporter/vitest` to build a test name that includes multi-project markers. The reporter parses the title and sets `testops_project_mapping`:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { addQaseId, addQaseProjects } from 'vitest-qase-reporter/vitest';
|
|
23
|
+
|
|
24
|
+
// Single project (legacy)
|
|
25
|
+
it(addQaseId('login flow', [100]), async () => { ... });
|
|
26
|
+
|
|
27
|
+
// Multi-project
|
|
28
|
+
it(addQaseProjects('login flow', { PROJ1: [100], PROJ2: [200] }), async () => { ... });
|
|
29
|
+
|
|
30
|
+
// Multiple IDs per project
|
|
31
|
+
it(addQaseProjects('checkout', { PROJ1: [10, 11], PROJ2: [20] }), async () => { ... });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Project codes must match `testops_multi.projects[].code` in your config.
|
|
35
|
+
|
|
36
|
+
## Tests Without Project Mapping
|
|
37
|
+
|
|
38
|
+
Tests whose name does not contain multi-project markers (and have no single-project `(Qase ID: …)`) are sent to the `default_project`. Results without any case ID are sent to the default project without linking to a test case.
|
|
39
|
+
|
|
40
|
+
## Important Notes
|
|
41
|
+
|
|
42
|
+
1. **Project codes must match**: Keys in `addQaseProjects('name', { PROJ1: [1], ... })` must match `testops_multi.projects[].code`.
|
|
43
|
+
2. **Mode**: Use `mode: 'testops_multi'` in Vitest reporter config.
|
|
44
|
+
3. **Title format**: The helper produces a title like `Name (Qase PROJ1: 1,2) (Qase PROJ2: 3)`.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
See the [multi-project Vitest example](../../examples/multiProject/vitest/) for a complete runnable setup.
|
|
49
|
+
|
|
50
|
+
## Troubleshooting
|
|
51
|
+
|
|
52
|
+
* Ensure `mode` is `testops_multi` and project codes match the config.
|
|
53
|
+
* Use `addQaseProjects(name, mapping)` (or an equivalent title format) so the reporter can parse the mapping from the test name.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-qase-reporter",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Qase TMS Vitest Reporter",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"author": "Qase Team <support@qase.io>",
|
|
41
41
|
"license": "Apache-2.0",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"qase-javascript-commons": "~2.
|
|
43
|
+
"qase-javascript-commons": "~2.5.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"vitest": ">=3.0.0"
|