@testomatio/reporter 0.4.5 → 0.5.0-beta.3

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.
Files changed (49) hide show
  1. package/.eslintrc.js +18 -22
  2. package/.github/workflows/node.js.yml +2 -1
  3. package/.prettierrc.js +12 -0
  4. package/Changelog.md +21 -17
  5. package/README.md +122 -93
  6. package/example/codecept/codecept.conf.js +7 -7
  7. package/example/codecept/index_test.js +8 -8
  8. package/example/codecept/sample_test.js +4 -4
  9. package/example/codecept/steps.d.ts +1 -1
  10. package/example/codecept/steps_file.js +4 -2
  11. package/example/core/index.js +6 -6
  12. package/example/jest/index.test.js +3 -3
  13. package/example/jest/jest.config.js +1 -1
  14. package/example/jest/sample.test.js +4 -4
  15. package/example/mocha/test/index.test.js +5 -5
  16. package/lib/adapter/codecept.js +72 -70
  17. package/lib/adapter/cucumber.js +35 -52
  18. package/lib/adapter/cypress-plugin/index.js +44 -0
  19. package/lib/adapter/jasmine.js +15 -6
  20. package/lib/adapter/jest.js +9 -10
  21. package/lib/adapter/mocha.js +17 -14
  22. package/lib/adapter/playwright.js +25 -25
  23. package/lib/adapter/webdriver.js +3 -3
  24. package/lib/bin/startTest.js +56 -60
  25. package/lib/client.js +59 -110
  26. package/lib/constants.js +6 -6
  27. package/lib/fileUploader.js +22 -19
  28. package/lib/output.js +6 -8
  29. package/lib/reporter.js +2 -2
  30. package/lib/util.js +18 -5
  31. package/package.json +29 -16
  32. package/testcafe/index.js +11 -14
  33. package/tests/adapter/config/index.js +10 -0
  34. package/tests/adapter/examples/codecept/codecept.conf.js +33 -0
  35. package/tests/adapter/examples/codecept/index_test.js +11 -0
  36. package/tests/adapter/examples/codecept/jsconfig.json +5 -0
  37. package/tests/adapter/examples/codecept/output/Test_for_suite_2_@Tc2171bd2.failed.png +0 -0
  38. package/tests/adapter/examples/codecept/output/Test_issue_for_suite_1_@Tca70c8c4.failed.png +0 -0
  39. package/tests/adapter/examples/codecept/sample_test.js +7 -0
  40. package/tests/adapter/examples/codecept/steps_file.js +10 -0
  41. package/tests/adapter/examples/jasmine/index.test.js +11 -0
  42. package/tests/adapter/examples/jasmine/passReporterOpts.sh +8 -0
  43. package/tests/adapter/examples/jest/index.test.js +11 -0
  44. package/tests/adapter/examples/jest/jest.config.js +4 -0
  45. package/tests/adapter/examples/mocha/index.test.js +13 -0
  46. package/tests/adapter/examples/mocha/mocha.config.js +4 -0
  47. package/tests/adapter/index.test.js +136 -0
  48. package/tests/adapter/utils/index.js +40 -0
  49. package/.prettierrc.json +0 -1
@@ -1,9 +1,9 @@
1
- describe("Suite 1", () => {
2
- test("Test addition", () => {
1
+ describe('Suite 1', () => {
2
+ test('Test addition', () => {
3
3
  expect(1 + 2).toBe(4);
4
4
  });
5
5
 
6
- test("Test some more addition", () => {
6
+ test('Test some more addition', () => {
7
7
  expect(1 + 2).toBe(3);
8
8
  });
9
9
  });
@@ -132,7 +132,7 @@ module.exports = {
132
132
  // snapshotSerializers: [],
133
133
 
134
134
  // The test environment that will be used for testing
135
- testEnvironment: "node",
135
+ testEnvironment: 'node',
136
136
 
137
137
  // Options that will be passed to the testEnvironment
138
138
  // testEnvironmentOptions: {},
@@ -1,13 +1,13 @@
1
- describe("Suite 2", () => {
2
- test("This is a sample test 3", () => {
1
+ describe('Suite 2', () => {
2
+ test('This is a sample test 3', () => {
3
3
  expect(1 + 2).toBe(3);
4
4
  });
5
5
 
6
- test("This is a sample test 4", () => {
6
+ test('This is a sample test 4', () => {
7
7
  expect(1 + 2).toBe(3);
8
8
  });
9
9
 
10
- test("Test for suite 2", () => {
10
+ test('Test for suite 2', () => {
11
11
  expect(1 + 2).toBe(3);
12
12
  });
13
13
  });
@@ -1,13 +1,13 @@
1
- const assert = require("assert");
1
+ const assert = require('assert');
2
2
 
3
- describe("Sample mocha suite", () => {
4
- it("Sample mocha test", () => {
3
+ describe('Sample mocha suite', () => {
4
+ it('Sample mocha test', () => {
5
5
  assert.equal([1, 2, 3].indexOf(4), 0);
6
6
  });
7
7
  });
8
8
 
9
- describe("Sample mocha suite 2", () => {
10
- it("Sample mocha test 2", () => {
9
+ describe('Sample mocha suite 2', () => {
10
+ it('Sample mocha test 2', () => {
11
11
  assert.equal(1, 1);
12
12
  });
13
13
  });
@@ -1,62 +1,46 @@
1
- /* eslint-disable no-param-reassign */
2
1
  if (!global.codeceptjs) {
3
- global.codeceptjs = require("codeceptjs");
2
+ // eslint-disable-next-line global-require
3
+ global.codeceptjs = require('codeceptjs');
4
4
  }
5
+
5
6
  const { event, recorder, codecept } = global.codeceptjs;
6
- const chalk = require("chalk");
7
- const TestomatClient = require("../client");
8
- const { FAILED } = require("../constants");
9
- const TRConstants = require("../constants");
10
- const upload = require("../fileUploader");
11
- const Output = require("../output");
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');
12
13
 
13
14
  let currentMetaStep = [];
15
+ let error;
14
16
  let stepShift = 0;
17
+
15
18
  const output = new Output({
16
- filterFn: (stack) => !stack.includes("codeceptjs/lib/output"), // output from codeceptjs
19
+ filterFn: stack => !stack.includes('codeceptjs/lib/output'), // output from codeceptjs
17
20
  });
21
+
18
22
  let stepStart = new Date();
19
23
 
20
24
  const MAJOR_VERSION = parseInt(codecept.version().match(/\d/)[0], 10);
21
25
 
26
+ const DATA_REGEXP = /[|\s]+?(\{".*\}|\[.*\])/;
27
+
22
28
  if (MAJOR_VERSION < 3) {
23
- console.log(
24
- "🔴 This reporter works with CodeceptJS 3+, please update your tests"
25
- );
29
+ console.log('🔴 This reporter works with CodeceptJS 3+, please update your tests');
26
30
  }
27
31
 
28
- const parseTest = (tags) => {
29
- if (tags) {
30
- for (const tag of tags) {
31
- if (tag.startsWith("@T")) {
32
- return tag.substring(2, tag.length);
33
- }
34
- }
35
- }
36
-
37
- return null;
38
- };
39
-
40
- const getTestAndMessage = (title) => {
41
- const testObj = { message: "" };
42
- const testArr = title.split(/\s(\|\s\{.*?\})/);
43
- testObj.title = testArr[0];
44
-
45
- return testObj;
46
- };
47
-
48
- module.exports = (config) => {
32
+ function CodeceptReporter(config) {
49
33
  let failedTests = [];
50
34
  let videos = [];
51
35
  const testTimeMap = {};
52
36
  const { apiKey } = config;
53
37
 
54
38
  if (!apiKey) {
55
- console.log("TESTOMATIO key is empty, ignoring reports");
39
+ console.log('TESTOMATIO key is empty, ignoring reports');
56
40
  return;
57
41
  }
58
42
 
59
- const getDuration = (test) => {
43
+ const getDuration = test => {
60
44
  if (testTimeMap[test.id]) {
61
45
  return Date.now() - testTimeMap[test.id];
62
46
  }
@@ -70,7 +54,7 @@ module.exports = (config) => {
70
54
 
71
55
  // Listening to events
72
56
  event.dispatcher.on(event.all.before, () => {
73
- recorder.add("Creating new run", () => client.createRun());
57
+ recorder.add('Creating new run', () => client.createRun());
74
58
  videos = [];
75
59
  });
76
60
 
@@ -83,7 +67,7 @@ module.exports = (config) => {
83
67
  });
84
68
  });
85
69
 
86
- event.dispatcher.on(event.test.started, (test) => {
70
+ event.dispatcher.on(event.test.started, test => {
87
71
  testTimeMap[test.id] = Date.now();
88
72
  });
89
73
 
@@ -91,14 +75,16 @@ module.exports = (config) => {
91
75
  if (videos.length && upload.isEnabled()) {
92
76
  console.log(TRConstants.APP_PREFIX, `🎞️ Uploading ${videos.length} videos...`);
93
77
 
94
- let promises = [];
78
+ const promises = [];
95
79
  for (const video of videos) {
96
80
  const { testId, title, path, type } = video;
97
81
  const file = { path, type, title };
98
- promises.push(client.addTestRun(testId, undefined, {
99
- ...stripExampleFromTitle(title),
100
- files: [file],
101
- }));
82
+ promises.push(
83
+ client.addTestRun(testId, undefined, {
84
+ ...stripExampleFromTitle(title),
85
+ files: [file],
86
+ }),
87
+ );
102
88
  }
103
89
  await Promise.all(promises);
104
90
  }
@@ -107,10 +93,10 @@ module.exports = (config) => {
107
93
  client.updateRunStatus(status);
108
94
  });
109
95
 
110
- event.dispatcher.on(event.test.passed, (test) => {
96
+ event.dispatcher.on(event.test.passed, test => {
111
97
  const { id, tags, title } = test;
112
98
  if (id && failedTests.includes(id)) {
113
- failedTests = failedTests.filter((failed) => id !== failed);
99
+ failedTests = failedTests.filter(failed => id !== failed);
114
100
  }
115
101
  const testId = parseTest(tags);
116
102
  const testObj = getTestAndMessage(title);
@@ -123,14 +109,19 @@ module.exports = (config) => {
123
109
  output.stop();
124
110
  });
125
111
 
126
- event.dispatcher.on(event.test.after, (test) => {
112
+ event.dispatcher.on(event.test.failed, (test, err) => {
113
+ error = err;
114
+ });
115
+
116
+ event.dispatcher.on(event.test.after, test => {
127
117
  if (test.state && test.state !== FAILED) return;
128
- const { id, tags, title, err, artifacts } = test;
118
+ if (test.err) error = test.err;
119
+ const { id, tags, title, artifacts } = test;
129
120
  failedTests.push(id || title);
130
121
  const testId = parseTest(tags);
131
122
  const testObj = getTestAndMessage(title);
132
- if (err && err.stack && test.steps && test.steps.length) {
133
- err.stack = test.steps[test.steps.length - 1].line();
123
+ if (error && error.stack && test.steps && test.steps.length) {
124
+ error.stack = test.steps[test.steps.length - 1].line();
134
125
  }
135
126
 
136
127
  const files = [];
@@ -140,7 +131,7 @@ module.exports = (config) => {
140
131
 
141
132
  client.addTestRun(testId, TRConstants.FAILED, {
142
133
  ...stripExampleFromTitle(title),
143
- error: err,
134
+ error,
144
135
  message: testObj.message,
145
136
  time: getDuration(test),
146
137
  files,
@@ -149,7 +140,7 @@ module.exports = (config) => {
149
140
  output.stop();
150
141
  });
151
142
 
152
- event.dispatcher.on(event.test.skipped, (test) => {
143
+ event.dispatcher.on(event.test.skipped, test => {
153
144
  const { tags, title } = test;
154
145
  const testId = parseTest(tags);
155
146
  const testObj = getTestAndMessage(title);
@@ -161,13 +152,13 @@ module.exports = (config) => {
161
152
  output.stop();
162
153
  });
163
154
 
164
- event.dispatcher.on(event.step.started, (step) => {
155
+ event.dispatcher.on(event.step.started, step => {
165
156
  stepShift = 0;
166
157
  step.started = true;
167
158
  stepStart = new Date();
168
159
  });
169
160
 
170
- event.dispatcher.on(event.step.finished, (step) => {
161
+ event.dispatcher.on(event.step.finished, step => {
171
162
  if (!step.started) return;
172
163
  let processingStep = step;
173
164
  const metaSteps = [];
@@ -177,24 +168,15 @@ module.exports = (config) => {
177
168
  }
178
169
  const shift = metaSteps.length;
179
170
 
180
- for (
181
- let i = 0;
182
- i < Math.max(currentMetaStep.length, metaSteps.length);
183
- i++
184
- ) {
171
+ for (let i = 0; i < Math.max(currentMetaStep.length, metaSteps.length); i++) {
185
172
  if (currentMetaStep[i] !== metaSteps[i]) {
186
173
  stepShift = 2 * i;
174
+ // eslint-disable-next-line no-continue
187
175
  if (!metaSteps[i]) continue;
188
176
  if (metaSteps[i].isBDD()) {
189
- output.push(
190
- repeat(stepShift) +
191
- chalk.bold(metaSteps[i].toString()) +
192
- metaSteps[i].comment
193
- );
177
+ output.push(repeat(stepShift) + chalk.bold(metaSteps[i].toString()) + metaSteps[i].comment);
194
178
  } else {
195
- output.push(
196
- repeat(stepShift) + chalk.green.bold(metaSteps[i].toString())
197
- );
179
+ output.push(repeat(stepShift) + chalk.green.bold(metaSteps[i].toString()));
198
180
  }
199
181
  }
200
182
  }
@@ -213,23 +195,43 @@ module.exports = (config) => {
213
195
  }
214
196
  });
215
197
 
216
- event.dispatcher.on(event.step.comment, (step) => {
198
+ event.dispatcher.on(event.step.comment, step => {
217
199
  output.push(chalk.cyan.bold(step.toString()));
218
200
  });
219
- };
201
+ }
220
202
 
221
- const DATA_REGEXP = /[|\s]+?(\{".*\}|\[.*\])/;
203
+ function parseTest(tags) {
204
+ if (tags) {
205
+ for (const tag of tags) {
206
+ if (tag.startsWith('@T')) {
207
+ return tag.substring(2, tag.length);
208
+ }
209
+ }
210
+ }
211
+
212
+ return null;
213
+ }
214
+
215
+ function getTestAndMessage(title) {
216
+ const testObj = { message: '' };
217
+ const testArr = title.split(/\s(\|\s\{.*?\})/);
218
+ testObj.title = testArr[0];
219
+
220
+ return testObj;
221
+ }
222
222
 
223
223
  function stripExampleFromTitle(title) {
224
224
  const res = title.match(DATA_REGEXP);
225
225
  if (!res) return { title, example: null };
226
226
 
227
227
  const example = JSON.parse(res[1]);
228
- title = title.replace(DATA_REGEXP, "").trim();
228
+ title = title.replace(DATA_REGEXP, '').trim();
229
229
 
230
230
  return { title, example };
231
231
  }
232
232
 
233
233
  function repeat(num) {
234
- return "".padStart(num, " ");
234
+ return ''.padStart(num, ' ');
235
235
  }
236
+
237
+ module.exports = CodeceptReporter;
@@ -1,24 +1,25 @@
1
- const { Formatter } = require("cucumber");
2
- const chalk = require("chalk");
3
- const { TestomatClient, TRConstants } = require("../reporter");
4
- const { parseTest } = require("../util");
5
-
6
- const createTestomatFormatter = (apiKey) => {
7
- if (!apiKey || apiKey === "") {
8
- console.log(chalk.red("TESTOMATIO key is empty, ignoring reports"));
1
+ // eslint-disable-next-line import/no-unresolved
2
+ const { Formatter } = require('cucumber');
3
+ const chalk = require('chalk');
4
+ const { TestomatClient, TRConstants } = require('../reporter');
5
+ const { parseTest } = require('../util');
6
+
7
+ const createTestomatFormatter = apiKey => {
8
+ if (!apiKey || apiKey === '') {
9
+ console.log(chalk.red('TESTOMATIO key is empty, ignoring reports'));
9
10
  }
10
11
 
11
12
  const documents = {};
12
13
  const dataTableMap = {};
13
14
 
14
- const addDocument = (gherkinDocument) => {
15
+ const addDocument = gherkinDocument => {
15
16
  documents[gherkinDocument.uri] = gherkinDocument.document;
16
17
  };
17
18
 
18
- const getTitle = (scenario) => {
19
+ const getTitle = scenario => {
19
20
  let { name } = scenario;
20
21
  if (scenario.tags.length) {
21
- let tags = "";
22
+ let tags = '';
22
23
  for (const tag of scenario.tags) {
23
24
  tags = `${tags} ${tag.name}`;
24
25
  }
@@ -27,18 +28,15 @@ const createTestomatFormatter = (apiKey) => {
27
28
  return name;
28
29
  };
29
30
 
30
- const getFeature = (uri) => documents[uri].feature;
31
+ const getFeature = uri => documents[uri].feature;
31
32
 
32
- const getScenario = (location) => {
33
+ const getScenario = location => {
33
34
  const { children } = getFeature(location.uri);
34
35
  for (const scenario of children) {
35
- if (
36
- scenario.type === "Scenario" &&
37
- scenario.location.line === location.line
38
- ) {
36
+ if (scenario.type === 'Scenario' && scenario.location.line === location.line) {
39
37
  return scenario;
40
38
  }
41
- if (scenario.type === "ScenarioOutline") {
39
+ if (scenario.type === 'ScenarioOutline') {
42
40
  for (const example of scenario.examples) {
43
41
  for (const tableBody of example.tableBody) {
44
42
  if (tableBody.location.line === location.line) {
@@ -53,19 +51,15 @@ const createTestomatFormatter = (apiKey) => {
53
51
  };
54
52
 
55
53
  const loadDataTable = (scenario, uri) => {
56
- if (scenario.type === "ScenarioOutline") {
54
+ if (scenario.type === 'ScenarioOutline') {
57
55
  for (const example of scenario.examples) {
58
56
  for (const tableBody of example.tableBody) {
59
- const dataMap = example.tableHeader.cells.reduce(
60
- (acc, cell, index) => {
61
- acc[cell.value] = tableBody.cells[index].value;
62
- return acc;
63
- },
64
- {}
65
- );
66
-
67
- dataTableMap[`${uri}:${tableBody.location.line}`] =
68
- JSON.stringify(dataMap);
57
+ const dataMap = example.tableHeader.cells.reduce((acc, cell, index) => {
58
+ acc[cell.value] = tableBody.cells[index].value;
59
+ return acc;
60
+ }, {});
61
+
62
+ dataTableMap[`${uri}:${tableBody.location.line}`] = JSON.stringify(dataMap);
69
63
  }
70
64
  }
71
65
  }
@@ -77,10 +71,10 @@ const createTestomatFormatter = (apiKey) => {
77
71
  loadDataTable(scenario, sourceLocation.uri);
78
72
  }
79
73
 
80
- return dataTableMap[key] || "";
74
+ return dataTableMap[key] || '';
81
75
  };
82
76
 
83
- const getTestId = (scenario) => {
77
+ const getTestId = scenario => {
84
78
  if (scenario) {
85
79
  for (const tag of scenario.tags) {
86
80
  const testId = parseTest(tag.name);
@@ -100,41 +94,30 @@ const createTestomatFormatter = (apiKey) => {
100
94
  this.client = new TestomatClient({ apiKey });
101
95
  this.status = TRConstants.PASSED;
102
96
 
103
- options.eventBroadcaster.on("gherkin-document", addDocument);
104
- options.eventBroadcaster.on("test-run-started", () =>
105
- this.client.createRun());
106
- options.eventBroadcaster.on(
107
- "test-case-finished",
108
- this.onTestCaseFinished.bind(this)
109
- );
110
- options.eventBroadcaster.on("test-run-finished", () =>
111
- this.client.updateRunStatus(this.status));
97
+ options.eventBroadcaster.on('gherkin-document', addDocument);
98
+ options.eventBroadcaster.on('test-run-started', () => this.client.createRun());
99
+ options.eventBroadcaster.on('test-case-finished', this.onTestCaseFinished.bind(this));
100
+ options.eventBroadcaster.on('test-run-finished', () => this.client.updateRunStatus(this.status));
112
101
  }
113
102
 
114
103
  onTestCaseFinished(event) {
115
104
  const scenario = getScenario(event.sourceLocation);
116
105
  const testId = getTestId(scenario);
117
- const status =
118
- event.result.status === "undefined"
119
- ? TRConstants.SKIPPED
120
- : event.result.status;
106
+ const status = event.result.status === 'undefined' ? TRConstants.SKIPPED : event.result.status;
121
107
 
122
108
  let example = getDataTableMap(scenario, event.sourceLocation);
123
109
  if (example) example = JSON.parse(example);
124
110
 
125
111
  if (!scenario.name) return;
126
112
 
127
- let message = "";
128
- let cliMessage = `- ${scenario.name}: ${chalk.bold(
129
- status.toUpperCase()
130
- )}`;
113
+ let message = '';
114
+ let cliMessage = `- ${scenario.name}: ${chalk.bold(status.toUpperCase())}`;
131
115
 
132
- if (event.result.status === "undefined") {
116
+ if (event.result.status === 'undefined') {
133
117
  cliMessage += chalk.yellow(
134
- " (undefined steps. Run Cucumber without this formatter and implement missing steps)"
118
+ ' (undefined steps. Run Cucumber without this formatter and implement missing steps)',
135
119
  );
136
- message =
137
- "Undefined steps. Implement missing steps and rerun this scenario";
120
+ message = 'Undefined steps. Implement missing steps and rerun this scenario';
138
121
  }
139
122
  console.log(cliMessage);
140
123
  if (status !== TRConstants.PASSED && status !== TRConstants.SKIPPED) {
@@ -0,0 +1,44 @@
1
+ const TRConstants = require('../../constants');
2
+ const { parseTest } = require('../../util');
3
+ const TestomatClient = require('../../client');
4
+
5
+ const testomatioReporter = on => {
6
+ const client = new TestomatClient({ apiKey: process.env.TESTOMATIO });
7
+
8
+ on('before:run', async () => {
9
+ await client.createRun();
10
+ });
11
+
12
+ on('after:spec', async (_spec, results) => {
13
+ const addSpecTestsPromises = [];
14
+
15
+ const videos = [results.video];
16
+
17
+ for (const test of results.tests) {
18
+ const latestAttempt = test.attempts[test.attempts.length - 1];
19
+ const time = latestAttempt.duration;
20
+ const error = latestAttempt.error;
21
+
22
+ const title = test.title[1]; // [0] - spec title, [1] - test title
23
+ const testId = parseTest(title);
24
+
25
+ const screenshots = results.screenshots
26
+ .filter(screenshot => screenshot.path.includes(title))
27
+ .map(screenshot => screenshot.path);
28
+ const files = [...videos, ...screenshots];
29
+
30
+ const state = test.state === 'passed' ? TRConstants.PASSED : TRConstants.FAILED;
31
+
32
+ addSpecTestsPromises.push(client.addTestRun(testId, state, { title, time, error, files }));
33
+ }
34
+
35
+ await Promise.all(addSpecTestsPromises);
36
+ });
37
+
38
+ on('after:run', async results => {
39
+ const status = results.totalFailed ? TRConstants.FAILED : TRConstants.PASSED;
40
+ await client.updateRunStatus(status);
41
+ });
42
+ };
43
+
44
+ module.exports = testomatioReporter;
@@ -1,6 +1,6 @@
1
- const TestomatClient = require("../client");
2
- const { parseTest, ansiRegExp } = require("../util");
3
- const { PASSED } = require("../constants");
1
+ const TestomatClient = require('../client');
2
+ const { parseTest, ansiRegExp } = require('../util');
3
+ const { PASSED, FAILED } = require('../constants');
4
4
 
5
5
  class JasmineReporter {
6
6
  constructor(options) {
@@ -8,7 +8,7 @@ class JasmineReporter {
8
8
  const { apiKey } = options;
9
9
 
10
10
  if (!apiKey) {
11
- console.log("TESTOMATIO key is empty, ignoring reports");
11
+ console.log('TESTOMATIO key is empty, ignoring reports');
12
12
  return;
13
13
  }
14
14
 
@@ -33,7 +33,7 @@ class JasmineReporter {
33
33
 
34
34
  const title = result.description;
35
35
  const { status } = result;
36
- let errorMessage = "";
36
+ let errorMessage = '';
37
37
 
38
38
  for (let i = 0; i < result.failedExpectations.length; i += 1) {
39
39
  errorMessage = `${errorMessage}Failure: ${result.failedExpectations[i].message}\n`;
@@ -42,7 +42,7 @@ class JasmineReporter {
42
42
  console.log(`${title} : ${PASSED}`);
43
43
  console.log(errorMessage);
44
44
  const testId = parseTest(title);
45
- errorMessage = errorMessage.replace(ansiRegExp(), "");
45
+ errorMessage = errorMessage.replace(ansiRegExp(), '');
46
46
  this.client.addTestRun(testId, status, {
47
47
  error: result.failedExpectations[0],
48
48
  message: errorMessage,
@@ -50,6 +50,15 @@ class JasmineReporter {
50
50
  time: this.getDuration(result),
51
51
  });
52
52
  }
53
+
54
+ jasmineDone(suiteInfo, done) {
55
+ if (!this.client) return;
56
+
57
+ const { overallStatus } = suiteInfo;
58
+ const status = overallStatus === 'failed' ? FAILED : PASSED;
59
+
60
+ this.client.updateRunStatus(status).then(() => done);
61
+ }
53
62
  }
54
63
 
55
64
  module.exports = JasmineReporter;
@@ -1,6 +1,6 @@
1
- const TestomatClient = require("../client");
2
- const TRConstants = require("../constants");
3
- const { parseTest, ansiRegExp } = require("../util");
1
+ const TestomatClient = require('../client');
2
+ const TRConstants = require('../constants');
3
+ const { parseTest, ansiRegExp } = require('../util');
4
4
 
5
5
  class JestReporter {
6
6
  constructor(globalConfig, options) {
@@ -9,7 +9,7 @@ class JestReporter {
9
9
  const { apiKey } = options;
10
10
 
11
11
  if (!apiKey) {
12
- console.log("TESTOMATIO key is empty, ignoring reports");
12
+ console.log('TESTOMATIO key is empty, ignoring reports');
13
13
  return;
14
14
  }
15
15
 
@@ -26,19 +26,19 @@ class JestReporter {
26
26
  let steps = null;
27
27
  const { status, title, duration, failureMessages } = result;
28
28
  if (failureMessages[0]) {
29
- let errorMessage = failureMessages[0].replace(ansiRegExp(), "");
30
- errorMessage = errorMessage.split("\n")[0];
29
+ let errorMessage = failureMessages[0].replace(ansiRegExp(), '');
30
+ errorMessage = errorMessage.split('\n')[0];
31
31
  error = {
32
32
  message: errorMessage,
33
33
  };
34
34
  steps = failureMessages[0];
35
35
  }
36
36
  const testId = parseTest(title);
37
- const deducedStatus = status === "pending" ? "skipped" : status;
37
+ const deducedStatus = status === 'pending' ? 'skipped' : status;
38
38
 
39
39
  // In jest if test is not matched with test name pattern it is considered as skipped.
40
40
  // So adding a check if it is skipped for real or because of test pattern
41
- if (!this._globalConfig.testNamePattern || deducedStatus !== "skipped") {
41
+ if (!this._globalConfig.testNamePattern || deducedStatus !== 'skipped') {
42
42
  this.client.addTestRun(testId, deducedStatus, {
43
43
  error,
44
44
  steps,
@@ -53,8 +53,7 @@ class JestReporter {
53
53
  if (!this.client) return;
54
54
 
55
55
  const { numFailedTests } = results;
56
- const status =
57
- numFailedTests === 0 ? TRConstants.PASSED : TRConstants.FAILED;
56
+ const status = numFailedTests === 0 ? TRConstants.PASSED : TRConstants.FAILED;
58
57
  this.client.updateRunStatus(status);
59
58
  }
60
59
  }