jest-qase-reporter 2.0.0 → 2.0.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
@@ -9,7 +9,7 @@ It can work in different test automation scenarios:
9
9
  Testing frameworks that use Jest as a test runner, such as Puppeteer, Appium, and Detox,
10
10
  can also be used with Jest reporter.
11
11
 
12
- To install the latest beta version, run:
12
+ To install the latest version, run:
13
13
 
14
14
  ```shell
15
15
  npm install --save-dev jest-qase-reporter
package/changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ # jest-qase-reporter@2.0.1
2
+
3
+ ## What's new
4
+
5
+ Fixed a bug when a test was marked as skipped.
6
+ This reporter has uploaded this test as blocked.
7
+ Right now the reporter will upload this test as skipped.
8
+
1
9
  # jest-qase-reporter@2.0.0
2
10
 
3
11
  ## What's new
@@ -24,4 +32,4 @@ The v2 series of the Jest reporter has significant interface changes:
24
32
  * New import path.
25
33
  * New configuration data scheme.
26
34
 
27
- See the README for reference and instructions on upgrading from v1.
35
+ See the README for reference and instructions on upgrading from v1.
@@ -1,6 +1,6 @@
1
- import { Reporter, Test, TestResult, Config } from '@jest/reporters';
1
+ import { Config, Reporter, Test, TestResult } from '@jest/reporters';
2
2
  import { Status } from '@jest/test-result';
3
- import { ConfigType, TestStatusEnum, ConfigLoader } from 'qase-javascript-commons';
3
+ import { ConfigLoader, ConfigType, TestStatusEnum } from 'qase-javascript-commons';
4
4
  export type JestQaseOptionsType = ConfigType;
5
5
  /**
6
6
  * @class JestQaseReporter
@@ -50,4 +50,22 @@ export declare class JestQaseReporter implements Reporter {
50
50
  * @see {Reporter.onRunComplete}
51
51
  */
52
52
  onRunComplete(): void;
53
+ /**
54
+ * @param {string} filePath
55
+ * @param {string} fullName
56
+ * @param {number[]} ids
57
+ * @private
58
+ */
59
+ private getSignature;
60
+ /**
61
+ * @param {string} filePath
62
+ * @param {string[]} suites
63
+ * @private
64
+ */
65
+ private getRelations;
66
+ /**
67
+ * @param {string} fullPath
68
+ * @private
69
+ */
70
+ private getCurrentTestPath;
53
71
  }
package/dist/reporter.js CHANGED
@@ -48,7 +48,8 @@ class JestQaseReporter {
48
48
  * @param {TestResult} result
49
49
  */
50
50
  onTestResult(_, result) {
51
- result.testResults.forEach(({ title, status, duration, failureMessages, failureDetails, }) => {
51
+ console.log(result);
52
+ result.testResults.forEach(({ title, fullName, ancestorTitles, status, duration, failureMessages, failureDetails, }) => {
52
53
  let error;
53
54
  if (status === 'failed') {
54
55
  error = new Error(failureDetails.map((item) => {
@@ -60,6 +61,7 @@ class JestQaseReporter {
60
61
  error.stack = failureMessages.join('\n\n');
61
62
  }
62
63
  const ids = JestQaseReporter.getCaseId(title);
64
+ const filePath = this.getCurrentTestPath(result.testFilePath);
63
65
  void this.reporter.addTestResult({
64
66
  attachments: [],
65
67
  author: null,
@@ -75,14 +77,14 @@ class JestQaseReporter {
75
77
  message: error?.message ?? null,
76
78
  muted: false,
77
79
  params: {},
78
- relations: {},
80
+ group_params: {},
81
+ relations: this.getRelations(filePath, ancestorTitles),
79
82
  run_id: null,
80
- signature: '',
83
+ signature: this.getSignature(filePath, fullName, ids),
81
84
  steps: [],
82
85
  testops_id: ids.length > 0 ? ids : null,
83
86
  id: (0, uuid_1.v4)(),
84
87
  title: title,
85
- // suiteTitle: ancestorTitles,
86
88
  });
87
89
  });
88
90
  }
@@ -97,6 +99,53 @@ class JestQaseReporter {
97
99
  onRunComplete() {
98
100
  void this.reporter.publish();
99
101
  }
102
+ /**
103
+ * @param {string} filePath
104
+ * @param {string} fullName
105
+ * @param {number[]} ids
106
+ * @private
107
+ */
108
+ getSignature(filePath, fullName, ids) {
109
+ let signature = filePath.split('/').join('::');
110
+ signature += '::' + fullName.toLowerCase().replace(/\s/g, '_');
111
+ if (ids.length > 0) {
112
+ signature += '::' + ids.join('::');
113
+ }
114
+ return signature;
115
+ }
116
+ /**
117
+ * @param {string} filePath
118
+ * @param {string[]} suites
119
+ * @private
120
+ */
121
+ getRelations(filePath, suites) {
122
+ const suite = {
123
+ data: [],
124
+ };
125
+ for (const part of filePath.split('/')) {
126
+ suite.data.push({
127
+ title: part,
128
+ public_id: null,
129
+ });
130
+ }
131
+ for (const part of suites) {
132
+ suite.data.push({
133
+ title: part,
134
+ public_id: null,
135
+ });
136
+ }
137
+ return {
138
+ suite: suite,
139
+ };
140
+ }
141
+ /**
142
+ * @param {string} fullPath
143
+ * @private
144
+ */
145
+ getCurrentTestPath(fullPath) {
146
+ const executionPath = process.cwd() + '/';
147
+ return fullPath.replace(executionPath, '');
148
+ }
100
149
  }
101
150
  exports.JestQaseReporter = JestQaseReporter;
102
151
  /**
@@ -107,7 +156,7 @@ JestQaseReporter.statusMap = {
107
156
  failed: qase_javascript_commons_1.TestStatusEnum.failed,
108
157
  skipped: qase_javascript_commons_1.TestStatusEnum.skipped,
109
158
  disabled: qase_javascript_commons_1.TestStatusEnum.disabled,
110
- pending: qase_javascript_commons_1.TestStatusEnum.blocked,
159
+ pending: qase_javascript_commons_1.TestStatusEnum.skipped,
111
160
  todo: qase_javascript_commons_1.TestStatusEnum.disabled,
112
161
  focused: qase_javascript_commons_1.TestStatusEnum.passed,
113
162
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-qase-reporter",
3
- "version": "2.0.0",
3
+ "version": "2.0.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",
48
+ "qase-javascript-commons": "~2.2.0",
49
49
  "uuid": "^9.0.0"
50
50
  },
51
51
  "devDependencies": {