@testomatio/reporter 0.8.0-beta.31 → 0.8.0-beta.32

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.
@@ -3,130 +3,129 @@ const { join, resolve } = require('path');
3
3
  const fs = require('fs');
4
4
  const os = require('os');
5
5
  const uuid = require('uuid');
6
-
7
6
  const { TESTOMAT_ARTIFACT_SUFFIX } = require('./constants');
8
7
  const { specificTestInfo } = require('./util');
9
8
 
10
9
  class ArtifactStorage {
11
- _tmpPrefix = "tsmt_reporter";
12
-
13
- constructor(params) {
14
- this.isFile = false;
15
- this.isMemory = true;
16
- this.storage = params?.toFile;
17
-
18
- if (this.storage) {
19
- this.isFile = true;
20
- this.isMemory = false;
21
- this.tmpDirFullpath = this.createTestomatTmpDir(this._tmpPrefix);
22
- debug('SAVE to tmp folder mode enabled!');
23
- }
10
+
11
+ constructor(params) {
12
+ this._tmpPrefix = "tsmt_reporter";
13
+ this.isFile = false;
14
+ this.isMemory = true;
15
+ this.storage = params?.toFile;
16
+
17
+ if (this.storage) {
18
+ this.isFile = true;
19
+ this.isMemory = false;
20
+ this.tmpDirFullpath = this.createTestomatTmpDir(this._tmpPrefix);
21
+ debug('SAVE to tmp folder mode enabled!');
24
22
  }
23
+ }
25
24
 
26
- static async storeToFile(tmpDirName, artifact, testSuffix = "test") {
27
- const suffix = TESTOMAT_ARTIFACT_SUFFIX + uuid.v4() + testSuffix;
28
- const dirpath = join(os.tmpdir(), tmpDirName);
29
- const filepath = resolve(dirpath, suffix + ".json");
25
+ static async storeToFile(tmpDirName, artifact, testSuffix = "test") {
26
+ const suffix = TESTOMAT_ARTIFACT_SUFFIX + uuid.v4() + testSuffix;
27
+ const dirpath = join(os.tmpdir(), tmpDirName);
28
+ const filepath = resolve(dirpath, `${suffix}.json`);
30
29
 
31
- return await fs.promises.appendFile(filepath, JSON.stringify(artifact));
32
- }
30
+ return fs.promises.appendFile(filepath, JSON.stringify(artifact));
31
+ }
33
32
 
34
- static async artifact(artifact, context) {
35
- //TODO: mode for different pre-hooks. As variant - "all-tests" || "only_fail"
36
- // const mode = process.env.TESTOMAT_ARTIFACTS || "only_fail";
33
+ static async artifact(artifact, context) {
34
+ // TODO: mode for different pre-hooks. As variant - "all-tests" || "only_fail"
35
+ // const mode = process.env.TESTOMAT_ARTIFACTS || "only_fail";
37
36
 
38
- if (Array.isArray(global.testomatioArtifacts)) {
39
- debug("Saving artifacts to global storage");
37
+ if (Array.isArray(global.testomatioArtifacts)) {
38
+ debug("Saving artifacts to global storage");
40
39
 
41
- global.testomatioArtifacts.push(artifact);
42
- }
40
+ global.testomatioArtifacts.push(artifact);
41
+ }
43
42
 
44
- if (global?.testomatioArtifacts === undefined) {
45
- const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
43
+ if (global?.testomatioArtifacts === undefined) {
44
+ const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
46
45
 
47
- const testSuffix = specificTestInfo(context.test);
46
+ const testSuffix = specificTestInfo(context.test);
48
47
 
49
- if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
50
- debug("Saving artifacts to memory tmp folder");
48
+ if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
49
+ debug("Saving artifacts to memory tmp folder");
51
50
 
52
- return await ArtifactStorage.storeToFile(tmpDirNames[tmpDirNames.length - 1], artifact, testSuffix);
53
- }
54
- }
51
+ return ArtifactStorage.storeToFile(tmpDirNames[tmpDirNames.length - 1], artifact, testSuffix);
52
+ }
55
53
  }
54
+ }
56
55
 
57
- async artifactByTestName(test) {
58
- const list = [];
56
+ async artifactByTestName(test) {
57
+ const list = [];
59
58
 
60
- if (this.isFile && this.tmpDirFullpath) {
61
- const files = fs.readdirSync(this.tmpDirFullpath);
59
+ if (this.isFile && this.tmpDirFullpath) {
60
+ const files = fs.readdirSync(this.tmpDirFullpath);
62
61
 
63
- for (const file of files) {
64
- if (file.includes(test)) {
65
- const buff = await fs.promises.readFile(this.tmpDirFullpath + "/" + file);
66
-
67
- list.push(JSON.parse(buff.toString()));
68
- }
69
- }
70
- }
62
+ for (const file of files) {
63
+ if (file.includes(test)) {
64
+ const buff = await fs.promises.readFile(`${this.tmpDirFullpath }/${ file}`);
71
65
 
72
- return list;
66
+ list.push(JSON.parse(buff.toString()));
67
+ }
68
+ }
73
69
  }
74
70
 
75
- async tmpContents() {
76
- const contents = [];
71
+ return list;
72
+ }
77
73
 
78
- if (this.isFile && this.tmpDirFullpath) {
79
- const files = fs.readdirSync(this.tmpDirFullpath);
74
+ async tmpContents() {
75
+ const contents = [];
80
76
 
81
- for (const file of files) {
82
- const buff = await fs.promises.readFile(this.tmpDirFullpath + "/" + file);
83
- const content = buff.toString();
77
+ if (this.isFile && this.tmpDirFullpath) {
78
+ const files = fs.readdirSync(this.tmpDirFullpath);
84
79
 
85
- contents.push(content);
86
- }
87
- }
80
+ for (const file of files) {
81
+ const buff = await fs.promises.readFile(`${this.tmpDirFullpath }/${ file}`);
82
+ const content = buff.toString();
88
83
 
89
- return contents;
84
+ contents.push(content);
85
+ }
90
86
  }
91
87
 
92
- createTestomatTmpDir(clientPrefix) {
93
- return fs.mkdtempSync(join(os.tmpdir(), clientPrefix));
94
- }
88
+ return contents;
89
+ }
95
90
 
96
- clearTmpDirByName(name) {
97
- const tmpDirPath = join(os.tmpdir(), name);
91
+ createTestomatTmpDir(clientPrefix) {
92
+ return fs.mkdtempSync(join(os.tmpdir(), clientPrefix));
93
+ }
98
94
 
99
- if (fs.existsSync(tmpDirPath)) {
100
- fs.rmSync(tmpDirPath, { recursive: true });
101
- debug(` Testomat tmpDir = ${tmpDirPath} was deleted successfully!`);
102
-
103
- return;
104
- }
105
- }
95
+ clearTmpDirByName(name) {
96
+ const tmpDirPath = join(os.tmpdir(), name);
106
97
 
107
- static tmpTestomatDirNames() {
108
- const subname = this._tmpPrefix || "tsmt_reporter";
98
+ if (fs.existsSync(tmpDirPath)) {
99
+ fs.rmSync(tmpDirPath, { recursive: true });
100
+ debug(` Testomat tmpDir = ${tmpDirPath} was deleted successfully!`);
109
101
 
110
- return fs.readdirSync(os.tmpdir(), { withFileTypes: true })
111
- .filter((item) => item.isDirectory())
112
- .map((item) => item.name)
113
- .filter((name) => name.includes(subname));
102
+
114
103
  }
104
+ }
115
105
 
116
- cleanup() {
117
- if (this.isFile && this.tmpDirFullpath) {
118
- const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
106
+ static tmpTestomatDirNames() {
107
+ const subname = this._tmpPrefix || "tsmt_reporter";
119
108
 
120
- if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
121
- for (const name of tmpDirNames) {
122
- this.clearTmpDirByName(name);
123
- }
124
- }
125
- }
126
- else {
127
- debug("The tmp folder has not been created! Nothing to delete");
109
+ return fs.readdirSync(os.tmpdir(), { withFileTypes: true })
110
+ .filter((item) => item.isDirectory())
111
+ .map((item) => item.name)
112
+ .filter((name) => name.includes(subname));
113
+ }
114
+
115
+ cleanup() {
116
+ if (this.isFile && this.tmpDirFullpath) {
117
+ const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
118
+
119
+ if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
120
+ for (const name of tmpDirNames) {
121
+ this.clearTmpDirByName(name);
128
122
  }
123
+ }
124
+ }
125
+ else {
126
+ debug("The tmp folder has not been created! Nothing to delete");
129
127
  }
128
+ }
130
129
  }
131
130
 
132
131
  module.exports = ArtifactStorage;
@@ -1,15 +1,15 @@
1
+ const chalk = require('chalk');
2
+ const TestomatClient = require('../client');
3
+ const { STATUS, APP_PREFIX } = require('../constants');
4
+ const upload = require('../fileUploader');
5
+ const Output = require('../output');
6
+
1
7
  if (!global.codeceptjs) {
2
8
  // eslint-disable-next-line global-require, import/no-extraneous-dependencies
3
9
  global.codeceptjs = require('codeceptjs');
4
10
  }
5
11
 
6
12
  const { event, recorder, codecept } = global.codeceptjs;
7
- const chalk = require('chalk');
8
- const TestomatClient = require('../client');
9
- const { FAILED } = require('../constants');
10
- const TRConstants = require('../constants');
11
- const upload = require('../fileUploader');
12
- const Output = require('../output');
13
13
 
14
14
  let currentMetaStep = [];
15
15
  let error;
@@ -68,15 +68,16 @@ function CodeceptReporter(config) {
68
68
 
69
69
  event.dispatcher.on(event.all.result, async () => {
70
70
  if (videos.length && upload.isArtifactsEnabled()) {
71
- console.log(TRConstants.APP_PREFIX, `🎞️ Uploading ${videos.length} videos...`);
71
+ console.log(APP_PREFIX, `🎞️ Uploading ${videos.length} videos...`);
72
72
 
73
73
  const promises = [];
74
74
  for (const video of videos) {
75
75
  const { testId, title, path, type } = video;
76
76
  const file = { path, type, title };
77
77
  promises.push(
78
- client.addTestRun(testId, undefined, {
78
+ client.addTestRun(undefined, {
79
79
  ...stripExampleFromTitle(title),
80
+ test_id: testId,
80
81
  files: [file],
81
82
  }),
82
83
  );
@@ -84,7 +85,7 @@ function CodeceptReporter(config) {
84
85
  await Promise.all(promises);
85
86
  }
86
87
 
87
- const status = failedTests.length === 0 ? TRConstants.PASSED : TRConstants.FAILED;
88
+ const status = failedTests.length === 0 ? STATUS.PASSED : STATUS.FAILED;
88
89
  client.updateRunStatus(status);
89
90
  });
90
91
 
@@ -95,12 +96,13 @@ function CodeceptReporter(config) {
95
96
  }
96
97
  const testId = parseTest(tags);
97
98
  const testObj = getTestAndMessage(title);
98
- client.addTestRun(testId, TRConstants.PASSED, {
99
+ client.addTestRun(STATUS.PASSED, {
99
100
  ...stripExampleFromTitle(title),
100
101
  suite_title: test.parent && test.parent.title,
101
102
  message: testObj.message,
102
103
  time: getDuration(test),
103
104
  steps: output.text(),
105
+ test_id: testId,
104
106
  });
105
107
  output.stop();
106
108
  });
@@ -119,9 +121,10 @@ function CodeceptReporter(config) {
119
121
  failedTests.push(id || title);
120
122
  const testId = parseTest(tags);
121
123
 
122
- client.addTestRun(testId, TRConstants.FAILED, {
124
+ client.addTestRun(STATUS.FAILED, {
123
125
  ...stripExampleFromTitle(title),
124
126
  suite_title: suite.title,
127
+ test_id: testId,
125
128
  error,
126
129
  time: 0,
127
130
  });
@@ -130,7 +133,7 @@ function CodeceptReporter(config) {
130
133
  });
131
134
 
132
135
  event.dispatcher.on(event.test.after, test => {
133
- if (test.state && test.state !== FAILED) return;
136
+ if (test.state && test.state !== STATUS.FAILED) return;
134
137
  if (test.err) error = test.err;
135
138
  const { id, tags, title, artifacts } = test;
136
139
  failedTests.push(id || title);
@@ -149,8 +152,9 @@ function CodeceptReporter(config) {
149
152
  if (aid.startsWith('trace')) files.push({ testId: id, title, path: artifacts[aid], type: 'application/zip' });
150
153
  }
151
154
 
152
- client.addTestRun(testId, TRConstants.FAILED, {
155
+ client.addTestRun(STATUS.FAILED, {
153
156
  ...stripExampleFromTitle(title),
157
+ test_id: testId,
154
158
  suite_title: test.parent && test.parent.title,
155
159
  error,
156
160
  message: testObj.message,
@@ -167,8 +171,9 @@ function CodeceptReporter(config) {
167
171
 
168
172
  const testId = parseTest(tags);
169
173
  const testObj = getTestAndMessage(title);
170
- client.addTestRun(testId, TRConstants.SKIPPED, {
174
+ client.addTestRun(STATUS.SKIPPED, {
171
175
  ...stripExampleFromTitle(title),
176
+ test_id: testId,
172
177
  suite_title: test.parent && test.parent.title,
173
178
  message: testObj.message,
174
179
  time: getDuration(test),
@@ -207,12 +212,13 @@ function CodeceptReporter(config) {
207
212
  currentMetaStep = metaSteps;
208
213
  stepShift = 2 * shift;
209
214
 
210
- let duration = new Date() - stepStart;
211
- if (duration) {
212
- duration = repeat(1) + chalk.grey(`(${duration}ms)`);
215
+ const durationMs = (+new Date() - (+stepStart));
216
+ let duration = '';
217
+ if (durationMs) {
218
+ duration = repeat(1) + chalk.grey(`(${durationMs}ms)`);
213
219
  }
214
220
 
215
- if (step.status === TRConstants.FAILED) {
221
+ if (step.status === STATUS.FAILED) {
216
222
  output.push(repeat(stepShift) + chalk.red(step.toString()) + duration);
217
223
  } else {
218
224
  output.push(repeat(stepShift) + step.toString() + duration);
@@ -2,7 +2,8 @@
2
2
  const { Formatter, formatterHelpers } = require("@cucumber/cucumber");
3
3
  const chalk = require('chalk');
4
4
  const fs = require('fs');
5
- const { TestomatClient, TRConstants } = require('../../reporter');
5
+ const { STATUS } = require('../../constants');
6
+ const TestomatClient = require('../../client');
6
7
 
7
8
  const { GherkinDocumentParser, PickleParser } = formatterHelpers
8
9
  const {
@@ -19,7 +20,7 @@ class CucumberReporter extends Formatter {
19
20
  this.cases = [];
20
21
 
21
22
  this.client = new TestomatClient();
22
- this.status = TRConstants.PASSED;
23
+ this.status = STATUS.PASSED;
23
24
 
24
25
  }
25
26
 
@@ -33,7 +34,8 @@ class CucumberReporter extends Formatter {
33
34
  const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
34
35
 
35
36
  let example;
36
- let status = TRConstants.PASSED;
37
+
38
+ let status = STATUS.PASSED;
37
39
  let color = 'green';
38
40
  let message;
39
41
 
@@ -41,22 +43,23 @@ class CucumberReporter extends Formatter {
41
43
 
42
44
  if (testCaseAttempt.worstTestStepResult) {
43
45
  if (testCaseAttempt.worstTestStepResult.status === 'SKIPPED') {
44
- status = TRConstants.SKIPPED;
46
+ status = STATUS.SKIPPED;
45
47
  }
46
48
  if (testCaseAttempt.worstTestStepResult.status === 'UNDEFINED') {
47
- status = TRConstants.SKIPPED;
49
+ status = STATUS.SKIPPED;
48
50
  message = 'Undefined steps. Implement missing steps and rerun this scenario';
49
51
  }
50
52
  if (testCaseAttempt.worstTestStepResult.status === 'FAILED') {
51
53
  message = testCaseAttempt?.worstTestStepResult?.message;
52
- status = TRConstants.FAILED;
54
+ status = STATUS.FAILED;
53
55
  }
54
56
  color = getStatusColor(testCaseAttempt.worstTestStepResult.status);
55
- if (status !== TRConstants.PASSED) this.failures.push(testCaseAttempt);
57
+ if (status !== STATUS.PASSED) this.failures.push(testCaseAttempt);
56
58
  }
57
59
 
58
60
  if (testCaseAttempt.pickle.astNodeIds.length > 1) {
59
61
  example = getExample(testCaseAttempt);
62
+ // @ts-ignore
60
63
  testCaseAttempt.example = example;
61
64
  }
62
65
 
@@ -70,8 +73,8 @@ class CucumberReporter extends Formatter {
70
73
  if (message) cliMessage += chalk.gray(message.split('\n')[0]);
71
74
  console.log(cliMessage);
72
75
 
73
- if (status !== TRConstants.PASSED && status !== TRConstants.SKIPPED) {
74
- this.status = TRConstants.FAILED;
76
+ if (status !== STATUS.PASSED && status !== STATUS.SKIPPED) {
77
+ this.status = STATUS.FAILED;
75
78
  }
76
79
 
77
80
  const time = Object.values(testCaseAttempt.stepResults)
@@ -80,12 +83,13 @@ class CucumberReporter extends Formatter {
80
83
 
81
84
  if (!this.client) return;
82
85
 
83
- this.client.addTestRun(testId, status, {
86
+ this.client.addTestRun(status, {
84
87
  // error: testCaseAttempt.worstTestStepResult.message,
85
88
  message,
86
89
  steps: getSteps(testCaseAttempt).map(s => s.toString()).join('\n').trim(),
87
90
  example: { ...example},
88
91
  title: scenario,
92
+ test_id: testId,
89
93
  time,
90
94
  });
91
95
  }
@@ -121,9 +125,9 @@ class CucumberReporter extends Formatter {
121
125
 
122
126
  if (!this.client) return;
123
127
 
124
- this.client.updateRunStatus(testRunFinished.success ? TRConstants.PASSED : TRConstants.FAILED)
128
+ this.client.updateRunStatus(testRunFinished.success ? STATUS.PASSED : STATUS.FAILED)
125
129
  }
126
- };
130
+ }
127
131
 
128
132
  function getSteps(tc) {
129
133
  const stepIds = Object.keys(tc.stepResults);
@@ -1,8 +1,9 @@
1
- // eslint-disable-next-line import/no-unresolved
1
+ // eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved
2
2
  const { Formatter } = require('cucumber');
3
3
  const chalk = require('chalk');
4
- const { TestomatClient, TRConstants } = require('../../reporter');
5
4
  const { parseTest } = require('../../util');
5
+ const { STATUS } = require('../../constants');
6
+ const TestomatClient = require('../../client');
6
7
 
7
8
  const createTestomatFormatter = apiKey => {
8
9
  if (!apiKey || apiKey === '') {
@@ -92,18 +93,18 @@ const createTestomatFormatter = apiKey => {
92
93
  if (!apiKey) return;
93
94
 
94
95
  this.client = new TestomatClient({ apiKey });
95
- this.status = TRConstants.PASSED;
96
+ this.status = STATUS.PASSED.toString();
96
97
 
97
98
  options.eventBroadcaster.on('gherkin-document', addDocument);
98
- options.eventBroadcaster.on('test-run-started', () => this.client.createRun());
99
+ options.eventBroadcaster.on('test-run-started', () => this?.client?.createRun());
99
100
  options.eventBroadcaster.on('test-case-finished', this.onTestCaseFinished.bind(this));
100
- options.eventBroadcaster.on('test-run-finished', () => this.client.updateRunStatus(this.status));
101
+ options.eventBroadcaster.on('test-run-finished', () => this?.client?.updateRunStatus(this.status));
101
102
  }
102
103
 
103
104
  onTestCaseFinished(event) {
104
105
  const scenario = getScenario(event.sourceLocation);
105
106
  const testId = getTestId(scenario);
106
- const status = event.result.status === 'undefined' ? TRConstants.SKIPPED : event.result.status;
107
+ const status = event.result.status === 'undefined' ? STATUS.SKIPPED : event.result.status;
107
108
 
108
109
  let example = getDataTableMap(scenario, event.sourceLocation);
109
110
  if (example) example = JSON.parse(example);
@@ -120,14 +121,17 @@ const createTestomatFormatter = apiKey => {
120
121
  message = 'Undefined steps. Implement missing steps and rerun this scenario';
121
122
  }
122
123
  console.log(cliMessage);
123
- if (status !== TRConstants.PASSED && status !== TRConstants.SKIPPED) {
124
- this.status = TRConstants.FAILED;
124
+ if (status !== STATUS.PASSED && status !== STATUS.SKIPPED) {
125
+ this.status = STATUS.FAILED;
125
126
  }
126
- this.client.addTestRun(testId, status, {
127
- error: event.result.exception,
127
+
128
+ this.client?.addTestRun(status, {
129
+ error: event.result.exception instanceof Error ? event.result.exception : undefined,
128
130
  message,
129
131
  example,
132
+ test_id: testId,
130
133
  title: getTitle(scenario),
134
+ suite_title: getTitle(getFeature(event.sourceLocation.uri)),
131
135
  });
132
136
  }
133
137
  };
@@ -1,4 +1,4 @@
1
- const TRConstants = require('../../constants');
1
+ const { STATUS } = require('../../constants');
2
2
  const { parseTest, parseSuite } = require('../../util');
3
3
  const TestomatClient = require('../../client');
4
4
 
@@ -57,16 +57,16 @@ const testomatioReporter = on => {
57
57
 
58
58
  let state;
59
59
  switch (test.state) {
60
- case 'passed': state = TRConstants.PASSED; break;
61
- case 'failed': state = TRConstants.FAILED; break;
60
+ case 'passed': state = STATUS.PASSED; break;
61
+ case 'failed': state = STATUS.FAILED; break;
62
62
  case 'skipped':
63
63
  case 'pending':
64
64
  default:
65
- state = TRConstants.SKIPPED;
65
+ state = STATUS.SKIPPED;
66
66
  }
67
67
 
68
- addSpecTestsPromises.push(client.addTestRun(testId, state, {
69
- title, time, example, error, files, suite_title: suiteTitle, suite_id: suiteId
68
+ addSpecTestsPromises.push(client.addTestRun(state, {
69
+ title, time, example, error, files, suite_title: suiteTitle, test_id: testId, suite_id: suiteId
70
70
  }));
71
71
  }
72
72
 
@@ -74,7 +74,7 @@ const testomatioReporter = on => {
74
74
  });
75
75
 
76
76
  on('after:run', async results => {
77
- const status = results.totalFailed ? TRConstants.FAILED : TRConstants.PASSED;
77
+ const status = results.totalFailed ? STATUS.FAILED : STATUS.PASSED;
78
78
  await client.updateRunStatus(status);
79
79
  });
80
80
  };
@@ -1,6 +1,6 @@
1
1
  const TestomatClient = require('../client');
2
2
  const { parseTest, ansiRegExp } = require('../util');
3
- const { PASSED, FAILED } = require('../constants');
3
+ const { STATUS } = require('../constants');
4
4
 
5
5
  class JasmineReporter {
6
6
  constructor(options) {
@@ -32,13 +32,14 @@ class JasmineReporter {
32
32
  errorMessage = `${errorMessage}Failure: ${result.failedExpectations[i].message}\n`;
33
33
  errorMessage = `${errorMessage}\n ${result.failedExpectations[i].stack}`;
34
34
  }
35
- console.log(`${title} : ${PASSED}`);
35
+ console.log(`${title} : ${STATUS.PASSED}`);
36
36
  console.log(errorMessage);
37
37
  const testId = parseTest(title);
38
38
  errorMessage = errorMessage.replace(ansiRegExp(), '');
39
- this.client.addTestRun(testId, status, {
39
+ this.client.addTestRun(status, {
40
40
  error: result.failedExpectations[0],
41
41
  message: errorMessage,
42
+ test_id: testId,
42
43
  title,
43
44
  time: this.getDuration(result),
44
45
  });
@@ -48,7 +49,7 @@ class JasmineReporter {
48
49
  if (!this.client) return;
49
50
 
50
51
  const { overallStatus } = suiteInfo;
51
- const status = overallStatus === 'failed' ? FAILED : PASSED;
52
+ const status = overallStatus === 'failed' ? STATUS.FAILED : STATUS.PASSED;
52
53
 
53
54
  this.client.updateRunStatus(status).then(() => done);
54
55
  }
@@ -1,5 +1,5 @@
1
1
  const TestomatClient = require('../client');
2
- const TRConstants = require('../constants');
2
+ const { STATUS } = require('../constants');
3
3
  const { parseTest, ansiRegExp } = require('../util');
4
4
 
5
5
  class JestReporter {
@@ -16,26 +16,22 @@ class JestReporter {
16
16
 
17
17
  const { testResults } = testResult;
18
18
  for (const result of testResults) {
19
- let error = null;
20
- let steps = null;
19
+ let error;
20
+ let steps;
21
21
  const { status, title, duration, failureMessages } = result;
22
22
  if (failureMessages[0]) {
23
23
  let errorMessage = failureMessages[0].replace(ansiRegExp(), '');
24
24
  errorMessage = errorMessage.split('\n')[0];
25
- error = {
26
- message: errorMessage,
27
- };
25
+ error = new Error(errorMessage);
28
26
  steps = failureMessages[0];
29
27
  }
30
28
  const testId = parseTest(title);
31
29
  const deducedStatus = status === 'pending' ? 'skipped' : status;
32
-
33
- const suite_title = result.ancestorTitles && result.ancestorTitles[result.ancestorTitles.length - 1];
34
30
  // In jest if test is not matched with test name pattern it is considered as skipped.
35
31
  // So adding a check if it is skipped for real or because of test pattern
36
32
  if (!this._globalConfig.testNamePattern || deducedStatus !== 'skipped') {
37
- this.client.addTestRun(testId, deducedStatus, {
38
- suite_title,
33
+ this.client.addTestRun(deducedStatus, {
34
+ test_id: testId,
39
35
  error,
40
36
  steps,
41
37
  title,
@@ -49,7 +45,7 @@ class JestReporter {
49
45
  if (!this.client) return;
50
46
 
51
47
  const { numFailedTests } = results;
52
- const status = numFailedTests === 0 ? TRConstants.PASSED : TRConstants.FAILED;
48
+ const status = numFailedTests === 0 ? STATUS.PASSED : STATUS.FAILED;
53
49
  this.client.updateRunStatus(status);
54
50
  }
55
51
  }