@testomatio/reporter 1.1.0-beta.label-assign → 1.1.0-beta.mocha-create.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.
@@ -27,12 +27,16 @@ function MochaReporter(runner, opts) {
27
27
 
28
28
  runner.on(EVENT_TEST_PASS, async test => {
29
29
  passes += 1;
30
+
30
31
  console.log(chalk.bold.green('✔'), test.fullTitle());
31
32
  const testId = parseTest(test.title);
32
-
33
+
33
34
  client.addTestRun(STATUS.PASSED, {
34
35
  test_id: testId,
36
+ suite_title: getSuiteTitle(test),
35
37
  title: test.title,
38
+ code: test.body.toString(),
39
+ file: getFile(test),
36
40
  time: test.duration,
37
41
  });
38
42
  });
@@ -43,6 +47,9 @@ function MochaReporter(runner, opts) {
43
47
  const testId = parseTest(test.title);
44
48
  client.addTestRun(STATUS.SKIPPED, {
45
49
  title: test.title,
50
+ suite_title: getSuiteTitle(test),
51
+ code: test.body.toString(),
52
+ file: getFile(test),
46
53
  test_id: testId,
47
54
  time: test.duration,
48
55
  });
@@ -55,8 +62,11 @@ function MochaReporter(runner, opts) {
55
62
 
56
63
  client.addTestRun(STATUS.FAILED, {
57
64
  error: err,
65
+ suite_title: getSuiteTitle(test),
66
+ file: getFile(test),
58
67
  test_id: testId,
59
68
  title: test.title,
69
+ code: test.body.toString(),
60
70
  time: test.duration,
61
71
  });
62
72
  });
@@ -72,3 +82,13 @@ function MochaReporter(runner, opts) {
72
82
  Mocha.utils.inherits(MochaReporter, Mocha.reporters.Spec);
73
83
 
74
84
  module.exports = MochaReporter;
85
+
86
+ function getSuiteTitle(test, pathArr = []) {
87
+ pathArr.push(test.parent.title);
88
+ if (test.parent.parent) getSuiteTitle(test.parent, pathArr);
89
+ return pathArr.reverse().filter(t => !!t).join(' / ');
90
+ }
91
+
92
+ function getFile(test) {
93
+ return test.parent.file?.replace(process.cwd(), '');
94
+ }
package/lib/client.js CHANGED
@@ -131,6 +131,7 @@ class Client {
131
131
  steps,
132
132
  code = null,
133
133
  title,
134
+ file,
134
135
  suite_title,
135
136
  suite_id,
136
137
  test_id,
@@ -188,6 +189,7 @@ class Client {
188
189
  status,
189
190
  stack,
190
191
  example,
192
+ file,
191
193
  code,
192
194
  title,
193
195
  suite_title,
@@ -175,13 +175,14 @@ class TestomatioPipe {
175
175
  * @returns
176
176
  */
177
177
  addTest(data) {
178
- debug('Adding test...');
179
178
  if (!this.isEnabled) return;
180
179
  if (!this.runId) return;
181
180
  data.api_key = this.apiKey;
182
181
  data.create = this.createNewTests;
183
182
  const json = JsonCycle.stringify(data);
184
183
 
184
+ debug('Adding test', json);
185
+
185
186
  return this.axios.post(`/api/reporter/${this.runId}/testrun`, json, {
186
187
  maxContentLength: Infinity,
187
188
  maxBodyLength: Infinity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.1.0-beta.label-assign",
3
+ "version": "1.1.0-beta.mocha-create.2",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",