jest-qase-reporter 2.0.0-beta.1 → 2.0.0-beta.2

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 CHANGED
@@ -1,11 +1,75 @@
1
- > # Qase TMS Jest reporter
2
- >
3
- > Publish results simple and easy.
1
+ # Qase TestOps Jest reporter
4
2
 
5
- ## How to integrate
3
+ Qase Jest reporter sends test results and metadata to Qase.io.
4
+ It can work in different test automation scenarios:
6
5
 
6
+ * Create new test cases in Qase from existing autotests.
7
+ * Report Jest test results to existing test cases in Qase.
8
+
9
+ Testing frameworks that use Jest as a test runner, such as Puppetteer, Appium, and Detox,
10
+ can also be used with Jest reporter.
11
+
12
+ Qase Jest reporter is currently in open beta stage for the version 2 series.
13
+ To install the latest beta version, run:ы
14
+
15
+ ```shell
16
+ npm install --save-dev jest-qase-reporter@beta
17
+ ```
18
+
19
+ # Contents
20
+
21
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
22
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
23
+
24
+ - [Getting started](#getting-started)
25
+ - [Using Reporter](#using-reporter)
26
+ - [Configuration](#configuration)
27
+ - [Requirements](#requirements)
28
+
29
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
30
+
31
+ ## Getting started
32
+
33
+ To report your tests results to Qase, install `jest-qase-reporter`,
34
+ and add a reporter config in the `jest.config.ts` file.
35
+ A minimal configuration needs just two things:
36
+
37
+ * Qase project code, for example, in https://app.qase.io/project/DEMO the code is `DEMO`.
38
+ * Qase API token, created on the [Apps page](https://app.qase.io/apps?app=jest-reporter).
39
+
40
+ ```js
41
+ module.exports = {
42
+ reporters: [
43
+ 'default',
44
+ [
45
+ 'jest-qase-reporter',
46
+ {
47
+ mode: 'testops',
48
+ testops: {
49
+ api: {
50
+ token: 'api_token'
51
+ },
52
+ project: 'project_code',
53
+ },
54
+ },
55
+ ],
56
+ ],
57
+ };
7
58
  ```
8
- npm install jest-qase-reporter
59
+
60
+ Now, run the Jest tests as usual.
61
+ Test results will be reported to a new test run in Qase.
62
+
63
+
64
+ ```console
65
+ $ npx jest
66
+ Determining test suites to run...
67
+ ...
68
+ qase: Project DEMO exists
69
+ qase: Using run 42 to publish test results
70
+ ...
71
+
72
+ Ran all test suites.
9
73
  ```
10
74
 
11
75
  ## Using Reporter
@@ -17,7 +81,7 @@ But if necessary, you can independently register the ID of already
17
81
  existing test cases from TMS before the executing tests. For example:
18
82
 
19
83
  ```typescript
20
- import { qase } from 'jest-qase-reporter/jest';
84
+ const { qase } = require("jest-qase-reporter/jest");
21
85
 
22
86
  describe('My First Test', () => {
23
87
  test(qase([1,2], 'Several ids'), () => {
@@ -61,14 +125,12 @@ https://app.qase.io/run/QASE_PROJECT_CODE
61
125
  Reporter options (* - required):
62
126
 
63
127
  - `mode` - `testops`/`off` Enables reporter, default - `off`
64
- - `debug` - Enables debug logging, defaule - `false`
128
+ - `debug` - Enables debug logging, default - `false`
65
129
  - `environment` - To execute with the sending of the envinroment information
66
130
  - *`testops.api.token` - Token for API access, you can find more information
67
131
  [here](https://developers.qase.io/#authentication)
68
- - *`testops.project` - Code of your project (can be extracted from main
69
- page of your project: `https://app.qase.io/project/DEMOTR` -
70
- `DEMOTR` is project code here)
71
- - `testops.run.id` - Pass Run ID
132
+ - *`testops.project` - Qase project code, for example, in https://app.qase.io/project/DEMO the code is `DEMO`
133
+ - `testops.run.id` - Qase test run ID, used when the test run was created earlier using CLI or API call.
72
134
  - `testops.run.title` - Set custom Run name, when new run is created
73
135
  - `testops.run.description` - Set custom Run description, when new run is created
74
136
  - `testops.run.complete` - Whether the run should be completed
@@ -82,18 +144,17 @@ module.exports = {
82
144
  [
83
145
  'jest-qase-reporter',
84
146
  {
85
- debug: true,
86
- environment: 1,
147
+ mode: 'testops',
87
148
  testops: {
88
149
  api: {
89
150
  token: 'api_key'
90
151
  },
91
152
  project: 'project_code',
92
153
  run: {
93
- id: 45,
94
154
  complete: true,
95
155
  },
96
156
  },
157
+ debug: true,
97
158
  },
98
159
  ],
99
160
  ],
package/changelog.md ADDED
@@ -0,0 +1,15 @@
1
+ # jest-qase-reporter@2.0.0-beta.2
2
+
3
+ ## What's new
4
+
5
+ * This release brings support for multiple changes made in the Qase API client
6
+ and the qase-javascript-commons library.
7
+
8
+ # jest-qase-reporter@2.0.0-beta.2
9
+
10
+ The v2 series of the Jest reporter has significant interface changes:
11
+
12
+ * New import path.
13
+ * New configuration data scheme.
14
+
15
+ See the README for reference and instructions on upgrading from v1.
package/dist/reporter.js CHANGED
@@ -30,7 +30,7 @@ class JestQaseReporter {
30
30
  */
31
31
  constructor(_, options, _state, configLoader = new qase_javascript_commons_1.ConfigLoader()) {
32
32
  const config = configLoader.load();
33
- this.reporter = new qase_javascript_commons_1.QaseReporter({
33
+ this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
34
34
  ...(0, qase_javascript_commons_1.composeOptions)(options, config),
35
35
  frameworkPackage: 'jest',
36
36
  frameworkName: 'jest',
@@ -40,13 +40,15 @@ class JestQaseReporter {
40
40
  /**
41
41
  * @see {Reporter.onRunStart}
42
42
  */
43
- onRunStart() { }
43
+ onRunStart() {
44
+ void this.reporter.startTestRun();
45
+ }
44
46
  /**
45
47
  * @param {Test} _
46
48
  * @param {TestResult} result
47
49
  */
48
50
  onTestResult(_, result) {
49
- result.testResults.forEach(({ ancestorTitles, title, status, duration, failureMessages, failureDetails, }) => {
51
+ result.testResults.forEach(({ title, status, duration, failureMessages, failureDetails, }) => {
50
52
  let error;
51
53
  if (status === 'failed') {
52
54
  error = new Error(failureDetails.map((item) => {
@@ -57,21 +59,38 @@ class JestQaseReporter {
57
59
  }).join('\n\n'));
58
60
  error.stack = failureMessages.join('\n\n');
59
61
  }
60
- this.reporter.addTestResult({
62
+ const ids = JestQaseReporter.getCaseId(title);
63
+ void this.reporter.addTestResult({
64
+ attachments: [],
65
+ author: null,
66
+ execution: {
67
+ status: JestQaseReporter.statusMap[status],
68
+ start_time: null,
69
+ end_time: null,
70
+ duration: duration ?? 0,
71
+ stacktrace: error?.stack ?? null,
72
+ thread: null,
73
+ },
74
+ fields: {},
75
+ message: error?.message ?? null,
76
+ muted: false,
77
+ params: {},
78
+ relations: {},
79
+ run_id: null,
80
+ signature: '',
81
+ steps: [],
82
+ testops_id: ids.length > 0 ? ids : null,
61
83
  id: (0, uuid_1.v4)(),
62
- testOpsId: JestQaseReporter.getCaseId(title),
63
84
  title: title,
64
- suiteTitle: ancestorTitles,
65
- status: JestQaseReporter.statusMap[status],
66
- duration: duration ?? 0,
67
- error,
85
+ // suiteTitle: ancestorTitles,
68
86
  });
69
87
  });
70
88
  }
71
89
  /**
72
90
  * @see {Reporter.getLastError}
73
91
  */
74
- getLastError() { }
92
+ getLastError() {
93
+ }
75
94
  /**
76
95
  * @see {Reporter.onRunComplete}
77
96
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-qase-reporter",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
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.0.0-beta.1",
48
+ "qase-javascript-commons": "^2.0.0-beta.12",
49
49
  "uuid": "^9.0.0"
50
50
  },
51
51
  "devDependencies": {