jest-qase-reporter 2.1.4 → 2.2.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/jest.d.ts +3 -0
- package/dist/jest.js +9 -0
- package/dist/reporter.js +10 -4
- package/docs/MULTI_PROJECT.md +53 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -135,6 +135,12 @@ A test run will be performed and available at:
|
|
|
135
135
|
https://app.qase.io/run/QASE_PROJECT_CODE
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
+
### Multi-Project Support
|
|
139
|
+
|
|
140
|
+
Qase Jest Reporter supports sending test results to multiple Qase projects simultaneously. You can specify different test case IDs for each project using `qase.projects(mapping, name)`.
|
|
141
|
+
|
|
142
|
+
For detailed information, configuration, and examples, see the [Multi-Project Support Guide](docs/MULTI_PROJECT.md).
|
|
143
|
+
|
|
138
144
|
## Configuration
|
|
139
145
|
|
|
140
146
|
Reporter options (* - required):
|
package/changelog.md
CHANGED
package/dist/jest.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { StepFunction } from 'qase-javascript-commons';
|
|
2
|
+
/** Project code → test case IDs for multi-project (testops_multi) mode. */
|
|
3
|
+
export type ProjectMapping = Record<string, number[]>;
|
|
2
4
|
export declare const qase: {
|
|
3
5
|
(caseId: number | string | number[] | string[], name: string): string;
|
|
6
|
+
projects(mapping: ProjectMapping, name: string): string;
|
|
4
7
|
title(value: string): void;
|
|
5
8
|
ignore(): void;
|
|
6
9
|
comment(value: string): void;
|
package/dist/jest.js
CHANGED
|
@@ -12,6 +12,15 @@ const qase = (caseId, name) => {
|
|
|
12
12
|
return `${name} (Qase ID: ${caseIds.join(',')})`;
|
|
13
13
|
};
|
|
14
14
|
exports.qase = qase;
|
|
15
|
+
/**
|
|
16
|
+
* Build test name with multi-project markers (for testops_multi mode).
|
|
17
|
+
* @param mapping — e.g. { PROJ1: [1, 2], PROJ2: [3] }
|
|
18
|
+
* @param name — test title
|
|
19
|
+
* @example test(qase.projects({ PROJ1: [100], PROJ2: [200] }, 'Login flow'), () => { ... });
|
|
20
|
+
*/
|
|
21
|
+
exports.qase.projects = (mapping, name) => {
|
|
22
|
+
return (0, qase_javascript_commons_1.formatTitleWithProjectMapping)(name, mapping);
|
|
23
|
+
};
|
|
15
24
|
/**
|
|
16
25
|
* Set a title for the test case
|
|
17
26
|
* @param {string} value
|
package/dist/reporter.js
CHANGED
|
@@ -245,11 +245,13 @@ class JestQaseReporter {
|
|
|
245
245
|
}).join('\n\n'));
|
|
246
246
|
error.stack = value.failureMessages.join('\n\n');
|
|
247
247
|
}
|
|
248
|
-
const
|
|
248
|
+
const parsed = (0, qase_javascript_commons_1.parseProjectMappingFromTitle)(value.title);
|
|
249
249
|
const filePath = this.getCurrentTestPath(path);
|
|
250
|
+
const hasProjectMapping = Object.keys(parsed.projectMapping).length > 0;
|
|
251
|
+
const ids = hasProjectMapping ? [] : parsed.legacyIds;
|
|
250
252
|
// Determine status based on error type
|
|
251
253
|
const testStatus = (0, qase_javascript_commons_1.determineTestStatus)(error ?? null, value.status);
|
|
252
|
-
|
|
254
|
+
const result = {
|
|
253
255
|
attachments: [],
|
|
254
256
|
author: null,
|
|
255
257
|
execution: {
|
|
@@ -269,10 +271,14 @@ class JestQaseReporter {
|
|
|
269
271
|
run_id: null,
|
|
270
272
|
signature: this.getSignature(filePath, value.fullName, ids, {}),
|
|
271
273
|
steps: [],
|
|
272
|
-
testops_id:
|
|
274
|
+
testops_id: parsed.legacyIds.length > 0 && !hasProjectMapping
|
|
275
|
+
? (parsed.legacyIds.length === 1 ? parsed.legacyIds[0] : parsed.legacyIds)
|
|
276
|
+
: null,
|
|
277
|
+
testops_project_mapping: hasProjectMapping ? parsed.projectMapping : null,
|
|
273
278
|
id: (0, uuid_1.v4)(),
|
|
274
|
-
title: this.removeQaseIdsFromTitle(value.title),
|
|
279
|
+
title: parsed.cleanedTitle || this.removeQaseIdsFromTitle(value.title),
|
|
275
280
|
};
|
|
281
|
+
return result;
|
|
276
282
|
}
|
|
277
283
|
/**
|
|
278
284
|
* @returns {Metadata}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Multi-Project Support in Jest
|
|
2
|
+
|
|
3
|
+
Qase Jest 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 Jest reporter options (e.g. in `jest.config.js` or `qase.config.json`) and add the `testops_multi` section with `default_project` and `projects`.
|
|
16
|
+
|
|
17
|
+
## Using `qase.projects(mapping, name)`
|
|
18
|
+
|
|
19
|
+
Use `qase.projects(mapping, name)` to set the test title with multi-project markers. The first argument is the mapping (project code → array of case IDs); the second is the test name. Use the returned string as the test name:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
const { qase } = require('jest-qase-reporter');
|
|
23
|
+
|
|
24
|
+
// Single project with single ID
|
|
25
|
+
test(qase(100, 'login flow'), () => { ... });
|
|
26
|
+
|
|
27
|
+
// Multi-project: one test, multiple projects
|
|
28
|
+
test(qase.projects({ PROJ1: [100], PROJ2: [200] }, 'login flow'), () => { ... });
|
|
29
|
+
|
|
30
|
+
// Multiple IDs per project
|
|
31
|
+
test(qase.projects({ PROJ1: [10, 11], PROJ2: [20] }, 'checkout'), () => { ... });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Project codes (e.g. `PROJ1`, `PROJ2`) must match `testops_multi.projects[].code` in your config.
|
|
35
|
+
|
|
36
|
+
## Tests Without Project Mapping
|
|
37
|
+
|
|
38
|
+
Tests that do not use `qase.projects()` and have no `(Qase PROJ: ids)` in the title are sent to the `default_project`. If they use `qase(id, name)` (single-project), that ID is used for the default project.
|
|
39
|
+
|
|
40
|
+
## Important Notes
|
|
41
|
+
|
|
42
|
+
1. **Project codes must match**: Codes in `qase.projects({ PROJ1: [1], ... })` must match `testops_multi.projects[].code`.
|
|
43
|
+
2. **Mode**: Set `mode` to `testops_multi` in reporter config.
|
|
44
|
+
3. **Title format**: The helper produces a title like `Name (Qase PROJ1: 1,2) (Qase PROJ2: 3)` so the reporter can parse the mapping.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
See the [multi-project Jest example](../../examples/multiProject/jest/) for a complete runnable setup.
|
|
49
|
+
|
|
50
|
+
## Troubleshooting
|
|
51
|
+
|
|
52
|
+
* Verify `mode` is `testops_multi` and project codes in `qase.projects()` match the config.
|
|
53
|
+
* Ensure the first argument to `test()` is the string returned by `qase.projects(mapping, name)` (or an equivalent title with markers).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-qase-reporter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Qase TMS Jest Reporter",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"lodash.get": "^4.4.2",
|
|
47
47
|
"lodash.has": "^4.5.2",
|
|
48
|
-
"qase-javascript-commons": "~2.
|
|
48
|
+
"qase-javascript-commons": "~2.5.0",
|
|
49
49
|
"uuid": "^9.0.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|