@testomatio/reporter 1.6.0-beta-2-artifacts → 2.0.0-beta-esm

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 (97) hide show
  1. package/lib/adapter/codecept.js +288 -330
  2. package/lib/adapter/cucumber/current.js +195 -203
  3. package/lib/adapter/cucumber/legacy.js +130 -155
  4. package/lib/adapter/cucumber.js +5 -16
  5. package/lib/adapter/cypress-plugin/index.js +91 -105
  6. package/lib/adapter/jasmine/jasmine.js +63 -0
  7. package/lib/adapter/jasmine.js +54 -53
  8. package/lib/adapter/jest.js +97 -99
  9. package/lib/adapter/mocha/mocha.js +125 -0
  10. package/lib/adapter/mocha.js +111 -140
  11. package/lib/adapter/playwright.js +168 -200
  12. package/lib/adapter/vitest.js +144 -143
  13. package/lib/adapter/webdriver.js +113 -97
  14. package/lib/bin/reportXml.js +49 -49
  15. package/lib/bin/startTest.js +80 -97
  16. package/lib/client.js +344 -385
  17. package/lib/config.js +16 -21
  18. package/lib/constants.js +49 -43
  19. package/lib/data-storage.js +206 -188
  20. package/lib/fileUploader.js +245 -0
  21. package/lib/junit-adapter/adapter.js +17 -20
  22. package/lib/junit-adapter/csharp.js +18 -14
  23. package/lib/junit-adapter/index.js +27 -25
  24. package/lib/junit-adapter/java.js +41 -53
  25. package/lib/junit-adapter/javascript.js +30 -27
  26. package/lib/junit-adapter/python.js +38 -37
  27. package/lib/junit-adapter/ruby.js +11 -8
  28. package/lib/output.js +44 -52
  29. package/lib/package.json +1 -0
  30. package/lib/pipe/bitbucket.js +208 -227
  31. package/lib/pipe/csv.js +111 -124
  32. package/lib/pipe/github.js +184 -211
  33. package/lib/pipe/gitlab.js +164 -205
  34. package/lib/pipe/html.js +253 -312
  35. package/lib/pipe/index.js +83 -63
  36. package/lib/pipe/testomatio.js +391 -454
  37. package/lib/reporter-functions.js +16 -20
  38. package/lib/reporter.js +47 -17
  39. package/lib/services/artifacts.js +55 -51
  40. package/lib/services/index.js +14 -12
  41. package/lib/services/key-values.js +56 -53
  42. package/lib/services/logger.js +227 -245
  43. package/lib/utils/chalk.js +10 -0
  44. package/lib/utils/pipe_utils.js +91 -84
  45. package/lib/utils/utils.js +289 -273
  46. package/lib/xmlReader.js +480 -519
  47. package/package.json +57 -19
  48. package/src/adapter/codecept.js +369 -0
  49. package/src/adapter/cucumber/current.js +228 -0
  50. package/src/adapter/cucumber/legacy.js +158 -0
  51. package/src/adapter/cucumber.js +4 -0
  52. package/src/adapter/cypress-plugin/index.js +110 -0
  53. package/src/adapter/jasmine.js +60 -0
  54. package/src/adapter/jest.js +107 -0
  55. package/src/adapter/mocha.cjs +2 -0
  56. package/src/adapter/mocha.js +156 -0
  57. package/src/adapter/playwright.js +222 -0
  58. package/src/adapter/vitest.js +183 -0
  59. package/src/adapter/webdriver.js +111 -0
  60. package/src/bin/reportXml.js +67 -0
  61. package/src/bin/startTest.js +119 -0
  62. package/src/client.js +423 -0
  63. package/src/config.js +30 -0
  64. package/src/constants.js +49 -0
  65. package/src/data-storage.js +204 -0
  66. package/src/fileUploader.js +307 -0
  67. package/src/junit-adapter/adapter.js +23 -0
  68. package/src/junit-adapter/csharp.js +16 -0
  69. package/src/junit-adapter/index.js +28 -0
  70. package/src/junit-adapter/java.js +58 -0
  71. package/src/junit-adapter/javascript.js +31 -0
  72. package/src/junit-adapter/python.js +42 -0
  73. package/src/junit-adapter/ruby.js +10 -0
  74. package/src/output.js +57 -0
  75. package/src/pipe/bitbucket.js +254 -0
  76. package/src/pipe/csv.js +140 -0
  77. package/src/pipe/github.js +234 -0
  78. package/src/pipe/gitlab.js +229 -0
  79. package/src/pipe/html.js +366 -0
  80. package/src/pipe/index.js +73 -0
  81. package/src/pipe/testomatio.js +498 -0
  82. package/src/reporter-functions.js +44 -0
  83. package/src/reporter.cjs +22 -0
  84. package/src/reporter.js +24 -0
  85. package/src/services/artifacts.js +59 -0
  86. package/src/services/index.js +13 -0
  87. package/src/services/key-values.js +59 -0
  88. package/src/services/logger.js +314 -0
  89. package/src/template/emptyData.svg +23 -0
  90. package/src/template/testomatio.hbs +1421 -0
  91. package/src/utils/chalk.js +13 -0
  92. package/src/utils/pipe_utils.js +127 -0
  93. package/src/utils/utils.js +341 -0
  94. package/src/xmlReader.js +551 -0
  95. package/lib/bin/cli.js +0 -216
  96. package/lib/bin/uploadArtifacts.js +0 -86
  97. package/lib/uploader.js +0 -312
@@ -1,155 +1,130 @@
1
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved
2
- const { Formatter } = require('cucumber');
3
- const chalk = require('chalk');
4
- const { getTestomatIdFromTestTitle, fileSystem } = require('../../utils/utils');
5
- const { STATUS, TESTOMAT_TMP_STORAGE_DIR } = require('../../constants');
6
- const TestomatClient = require('../../client');
7
- const config = require('../../config');
8
-
9
- const createTestomatFormatter = apiKey => {
10
- if (!apiKey || apiKey === '') {
11
- console.log(chalk.red('TESTOMATIO key is empty, ignoring reports'));
12
- }
13
-
14
- const documents = {};
15
- const dataTableMap = {};
16
-
17
- const addDocument = gherkinDocument => {
18
- documents[gherkinDocument.uri] = gherkinDocument.document;
19
- };
20
-
21
- const getTitle = scenario => {
22
- let { name } = scenario;
23
- if (scenario.tags.length) {
24
- let tags = '';
25
- for (const tag of scenario.tags) {
26
- tags = `${tags} ${tag.name}`;
27
- }
28
- name = `${name}${tags}`;
29
- }
30
- return name;
31
- };
32
-
33
- const getFeature = uri => documents[uri].feature;
34
-
35
- const getScenario = location => {
36
- const { children } = getFeature(location.uri);
37
- for (const scenario of children) {
38
- if (scenario.type === 'Scenario' && scenario.location.line === location.line) {
39
- return scenario;
40
- }
41
- if (scenario.type === 'ScenarioOutline') {
42
- for (const example of scenario.examples) {
43
- for (const tableBody of example.tableBody) {
44
- if (tableBody.location.line === location.line) {
45
- return scenario;
46
- }
47
- }
48
- }
49
- }
50
- }
51
-
52
- return null;
53
- };
54
-
55
- const loadDataTable = (scenario, uri) => {
56
- if (scenario.type === 'ScenarioOutline') {
57
- for (const example of scenario.examples) {
58
- for (const tableBody of example.tableBody) {
59
- const dataMap = example.tableHeader.cells.reduce((acc, cell, index) => {
60
- acc[cell.value] = tableBody.cells[index].value;
61
- return acc;
62
- }, {});
63
-
64
- dataTableMap[`${uri}:${tableBody.location.line}`] = JSON.stringify(dataMap);
65
- }
66
- }
67
- }
68
- };
69
-
70
- const getDataTableMap = (scenario, sourceLocation) => {
71
- const key = `${sourceLocation.uri}:${sourceLocation.line}`;
72
- if (!dataTableMap[key]) {
73
- loadDataTable(scenario, sourceLocation.uri);
74
- }
75
-
76
- return dataTableMap[key] || '';
77
- };
78
-
79
- const getTestId = scenario => {
80
- if (scenario) {
81
- for (const tag of scenario.tags) {
82
- const testId = getTestomatIdFromTestTitle(tag.name);
83
- if (testId) return testId;
84
- }
85
- }
86
-
87
- return null;
88
- };
89
-
90
- return class TestomatFormatter extends Formatter {
91
- constructor(options) {
92
- super(options);
93
-
94
- if (!apiKey) return;
95
-
96
- this.client = new TestomatClient({ apiKey });
97
- this.status = STATUS.PASSED.toString();
98
-
99
- options.eventBroadcaster.on('gherkin-document', addDocument);
100
- options.eventBroadcaster.on('test-run-started', () => {
101
- fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
102
- this?.client?.createRun();
103
- });
104
- options.eventBroadcaster.on('test-case-finished', this.onTestCaseFinished.bind(this));
105
- options.eventBroadcaster.on('test-case-started', this.onTestCaseStarted.bind(this));
106
- options.eventBroadcaster.on('test-run-finished', () => this?.client?.updateRunStatus(this.status));
107
-
108
- global.testomatioRunningEnvironment = 'cucumber:legacy';
109
- }
110
-
111
- onTestCaseStarted(event) {
112
- const scenario = getScenario(event.sourceLocation);
113
- const testId = getTestId(scenario);
114
-
115
- if (!global.testomatioDataStore) global.testomatioDataStore = {};
116
- global.testomatioDataStore.currentlyRunningTestId = testId;
117
- }
118
-
119
- onTestCaseFinished(event) {
120
- const scenario = getScenario(event.sourceLocation);
121
- const testId = getTestId(scenario);
122
- const status = event.result.status === 'undefined' ? STATUS.SKIPPED : event.result.status;
123
-
124
- let example = getDataTableMap(scenario, event.sourceLocation);
125
- if (example) example = JSON.parse(example);
126
-
127
- if (!scenario.name) return;
128
-
129
- const message = '';
130
- const cliMessage = `- ${scenario.name}: ${chalk.bold(status.toUpperCase())}`;
131
-
132
- // if (event.result.status === 'undefined') {
133
- // cliMessage += chalk.yellow(
134
- // ' (undefined steps. Run Cucumber without this formatter and implement missing steps)',
135
- // );
136
- // message = 'Undefined steps. Implement missing steps and rerun this scenario';
137
- // }
138
- console.log(cliMessage);
139
- if (status !== STATUS.PASSED && status !== STATUS.SKIPPED) {
140
- this.status = STATUS.FAILED;
141
- }
142
-
143
- this.client?.addTestRun(status, {
144
- error: event.result.exception instanceof Error ? event.result.exception : undefined,
145
- message,
146
- example,
147
- test_id: testId,
148
- title: getTitle(scenario),
149
- suite_title: getTitle(getFeature(event.sourceLocation.uri)),
150
- });
151
- }
152
- };
153
- };
154
-
155
- module.exports = createTestomatFormatter(config.TESTOMATIO);
1
+ // import { Formatter } from 'cucumber';
2
+ // import pc from 'picocolors';
3
+ // import { getTestomatIdFromTestTitle, fileSystem } from '../../utils/utils.js';
4
+ // import { STATUS, TESTOMAT_TMP_STORAGE_DIR } from '../../constants.js';
5
+ // import TestomatClient from '../../client.js';
6
+ // import {config} from '../../config.js';
7
+ // const createTestomatFormatter = apiKey => {
8
+ // if (!apiKey || apiKey === '') {
9
+ // console.log(pc.red('TESTOMATIO key is empty, ignoring reports'));
10
+ // }
11
+ // const documents = {};
12
+ // const dataTableMap = {};
13
+ // const addDocument = gherkinDocument => {
14
+ // documents[gherkinDocument.uri] = gherkinDocument.document;
15
+ // };
16
+ // const getTitle = scenario => {
17
+ // let { name } = scenario;
18
+ // if (scenario.tags.length) {
19
+ // let tags = '';
20
+ // for (const tag of scenario.tags) {
21
+ // tags = `${tags} ${tag.name}`;
22
+ // }
23
+ // name = `${name}${tags}`;
24
+ // }
25
+ // return name;
26
+ // };
27
+ // const getFeature = uri => documents[uri].feature;
28
+ // const getScenario = location => {
29
+ // const { children } = getFeature(location.uri);
30
+ // for (const scenario of children) {
31
+ // if (scenario.type === 'Scenario' && scenario.location.line === location.line) {
32
+ // return scenario;
33
+ // }
34
+ // if (scenario.type === 'ScenarioOutline') {
35
+ // for (const example of scenario.examples) {
36
+ // for (const tableBody of example.tableBody) {
37
+ // if (tableBody.location.line === location.line) {
38
+ // return scenario;
39
+ // }
40
+ // }
41
+ // }
42
+ // }
43
+ // }
44
+ // return null;
45
+ // };
46
+ // const loadDataTable = (scenario, uri) => {
47
+ // if (scenario.type === 'ScenarioOutline') {
48
+ // for (const example of scenario.examples) {
49
+ // for (const tableBody of example.tableBody) {
50
+ // const dataMap = example.tableHeader.cells.reduce((acc, cell, index) => {
51
+ // acc[cell.value] = tableBody.cells[index].value;
52
+ // return acc;
53
+ // }, {});
54
+ // dataTableMap[`${uri}:${tableBody.location.line}`] = JSON.stringify(dataMap);
55
+ // }
56
+ // }
57
+ // }
58
+ // };
59
+ // const getDataTableMap = (scenario, sourceLocation) => {
60
+ // const key = `${sourceLocation.uri}:${sourceLocation.line}`;
61
+ // if (!dataTableMap[key]) {
62
+ // loadDataTable(scenario, sourceLocation.uri);
63
+ // }
64
+ // return dataTableMap[key] || '';
65
+ // };
66
+ // const getTestId = scenario => {
67
+ // if (scenario) {
68
+ // for (const tag of scenario.tags) {
69
+ // const testId = getTestomatIdFromTestTitle(tag.name);
70
+ // if (testId) return testId;
71
+ // }
72
+ // }
73
+ // return null;
74
+ // };
75
+ // return class TestomatFormatter extends Formatter {
76
+ // constructor(options) {
77
+ // super(options);
78
+ // if (!apiKey) return;
79
+ // this.client = new TestomatClient({ apiKey });
80
+ // this.status = STATUS.PASSED.toString();
81
+ // options.eventBroadcaster.on('gherkin-document', addDocument);
82
+ // options.eventBroadcaster.on('test-run-started', () => {
83
+ // fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
84
+ // this?.client?.createRun();
85
+ // });
86
+ // options.eventBroadcaster.on('test-case-finished', this.onTestCaseFinished.bind(this));
87
+ // options.eventBroadcaster.on('test-case-started', this.onTestCaseStarted.bind(this));
88
+ // // @ts-ignore
89
+ // options.eventBroadcaster.on('test-run-finished', () => this?.client?.updateRunStatus(this.status));
90
+ // global.testomatioRunningEnvironment = 'cucumber:legacy';
91
+ // }
92
+ // onTestCaseStarted(event) {
93
+ // const scenario = getScenario(event.sourceLocation);
94
+ // const testId = getTestId(scenario);
95
+ // if (!global.testomatioDataStore) global.testomatioDataStore = {};
96
+ // global.testomatioDataStore.currentlyRunningTestId = testId;
97
+ // }
98
+ // onTestCaseFinished(event) {
99
+ // const scenario = getScenario(event.sourceLocation);
100
+ // const testId = getTestId(scenario);
101
+ // const status = event.result.status === 'undefined' ? STATUS.SKIPPED : event.result.status;
102
+ // let example = getDataTableMap(scenario, event.sourceLocation);
103
+ // if (example) example = JSON.parse(example);
104
+ // if (!scenario.name) return;
105
+ // const message = '';
106
+ // const cliMessage = `- ${scenario.name}: ${pc.bold(status.toUpperCase())}`;
107
+ // // if (event.result.status === 'undefined') {
108
+ // // cliMessage += pc.yellow(
109
+ // // ' (undefined steps. Run Cucumber without this formatter and implement missing steps)',
110
+ // // );
111
+ // // message = 'Undefined steps. Implement missing steps and rerun this scenario';
112
+ // // }
113
+ // console.log(cliMessage);
114
+ // if (status !== STATUS.PASSED && status !== STATUS.SKIPPED) {
115
+ // this.status = STATUS.FAILED;
116
+ // }
117
+ // this.client?.addTestRun(status, {
118
+ // error: event.result.exception instanceof Error ? event.result.exception : undefined,
119
+ // message,
120
+ // example,
121
+ // test_id: testId,
122
+ // title: getTitle(scenario),
123
+ // suite_title: getTitle(getFeature(event.sourceLocation.uri)),
124
+ // });
125
+ // }
126
+ // };
127
+ // };
128
+ // const CucumberLegacyReporter = createTestomatFormatter(config.TESTOMATIO);
129
+ // export { CucumberLegacyReporter };
130
+ // export default CucumberLegacyReporter;
@@ -1,16 +1,5 @@
1
- try {
2
- // eslint-disable-next-line import/no-unresolved
3
- require.resolve('@cucumber/cucumber');
4
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies
5
- module.exports = require('./cucumber/current');
6
- } catch (_e) {
7
- try {
8
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies
9
- require.resolve('cucumber');
10
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies
11
- module.exports = require('./cucumber/legacy');
12
- } catch (_err) {
13
- console.error('Cucumber packages: "@cucumber/cucumber" or "cucumber" were not detected. Report won\'t be sent');
14
- module.exports = {};
15
- }
16
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const current_js_1 = require("./cucumber/current.js");
4
+ // import { CucumberLegacyReporter } from './cucumber/legacy.js';
5
+ module.exports = current_js_1.CucumberReporter;
@@ -1,109 +1,95 @@
1
- const { STATUS } = require('../../constants');
2
- const { getTestomatIdFromTestTitle, parseSuite } = require('../../utils/utils');
3
- const TestomatClient = require('../../client');
4
- const config = require('../../config');
5
-
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const constants_js_1 = require("../../constants.js");
7
+ const utils_js_1 = require("../../utils/utils.js");
8
+ const client_js_1 = __importDefault(require("../../client.js"));
9
+ const config_js_1 = require("../../config.js");
6
10
  const testomatioReporter = on => {
7
- if (!config.TESTOMATIO) {
8
- console.log('TESTOMATIO key is empty, ignoring reports');
9
- return;
10
- }
11
- const client = new TestomatClient({ apiKey: config.TESTOMATIO });
12
-
13
- on('before:run', async run => {
14
- // TODO: looks like client.env does not exist
15
- if (!client.env) {
16
- client.env = `${run.browser.displayName},${run.system.osName}`;
17
- }
18
- await client.createRun();
19
- });
20
-
21
- on('after:spec', async (_spec, results) => {
22
- const addSpecTestsPromises = [];
23
-
24
- const videos = [results.video];
25
-
26
- for (const test of results.tests) {
27
- const lastAttemptIndex = test.attempts.length - 1;
28
- const latestAttempt = test.attempts[lastAttemptIndex];
29
-
30
- // latestAttempt.duration && latestAttempt.error were available in adapters version up to 13 JFYI
31
- const time = latestAttempt.duration || latestAttempt.wallClockDuration || test.duration;
32
- let error = latestAttempt.error;
33
-
34
- let title = test.title.pop();
35
- const examples = title.match(/\(example (#\d+)\)/);
36
- let example = null;
37
- if (examples && examples[1]) example = { example: examples[1] };
38
- title = title.replace(/\(example #\d+\)/, '').trim();
39
-
40
- const suiteTitle = test.title.pop();
41
-
42
- const testId = getTestomatIdFromTestTitle(title);
43
- const suiteId = parseSuite(suiteTitle);
44
-
45
- if (!error && test.displayError) {
46
- error = { message: test.displayError };
47
- error.inspect = function () {
48
- // eslint-disable-line func-names
49
- return this.message;
50
- };
51
- }
52
-
53
- const formattedError = error
54
- ? {
55
- message: error.message,
56
- inspect:
57
- error.inspect ||
58
- function () {
59
- return this.message;
60
- },
61
- }
62
- : '';
63
-
64
- const screenshots = Array.isArray(results.screenshots)
65
- ? results.screenshots
66
- .filter(screenshot => screenshot?.path && screenshot?.path.includes(title) && screenshot?.takenAt)
67
- .map(screenshot => screenshot.path)
68
- : [];
69
-
70
- const files = [...videos, ...screenshots];
71
-
72
- let state;
73
- switch (test.state) {
74
- case 'passed':
75
- state = STATUS.PASSED;
76
- break;
77
- case 'failed':
78
- state = STATUS.FAILED;
79
- break;
80
- case 'skipped':
81
- case 'pending':
82
- default:
83
- state = STATUS.SKIPPED;
84
- }
85
-
86
- addSpecTestsPromises.push(
87
- client.addTestRun(state, {
88
- title,
89
- time,
90
- example,
91
- error: formattedError,
92
- files,
93
- suite_title: suiteTitle,
94
- test_id: testId,
95
- suite_id: suiteId,
96
- }),
97
- );
11
+ if (!config_js_1.config.TESTOMATIO) {
12
+ console.log('TESTOMATIO key is empty, ignoring reports');
13
+ return;
98
14
  }
99
-
100
- await Promise.all(addSpecTestsPromises);
101
- });
102
-
103
- on('after:run', async results => {
104
- const status = results.totalFailed ? STATUS.FAILED : STATUS.PASSED;
105
- await client.updateRunStatus(status);
106
- });
15
+ const client = new client_js_1.default({ apiKey: config_js_1.config.TESTOMATIO });
16
+ on('before:run', async () => {
17
+ // TODO: looks like client.env does not exist
18
+ // if (!client.env) {
19
+ // client.env = `${run.browser.displayName},${run.system.osName}`;
20
+ // }
21
+ await client.createRun();
22
+ });
23
+ on('after:spec', async (_spec, results) => {
24
+ const addSpecTestsPromises = [];
25
+ const videos = [results.video];
26
+ for (const test of results.tests) {
27
+ const lastAttemptIndex = test.attempts.length - 1;
28
+ const latestAttempt = test.attempts[lastAttemptIndex];
29
+ // latestAttempt.duration && latestAttempt.error were available in adapters version up to 13 JFYI
30
+ const time = latestAttempt.duration || latestAttempt.wallClockDuration || test.duration;
31
+ let error = latestAttempt.error;
32
+ let title = test.title.pop();
33
+ const examples = title.match(/\(example (#\d+)\)/);
34
+ let example = null;
35
+ if (examples && examples[1])
36
+ example = { example: examples[1] };
37
+ title = title.replace(/\(example #\d+\)/, '').trim();
38
+ const suiteTitle = test.title.pop();
39
+ const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(title);
40
+ const suiteId = (0, utils_js_1.parseSuite)(suiteTitle);
41
+ if (!error && test.displayError) {
42
+ error = { message: test.displayError };
43
+ // eslint-disable-next-line
44
+ error.inspect = function () {
45
+ return this.message;
46
+ };
47
+ }
48
+ const formattedError = error ? {
49
+ message: error.message,
50
+ name: error.name,
51
+ inspect: error.inspect ||
52
+ // eslint-disable-next-line
53
+ function () {
54
+ return this.message;
55
+ },
56
+ } : undefined;
57
+ const screenshots = Array.isArray(results.screenshots)
58
+ ? results.screenshots
59
+ .filter(screenshot => screenshot?.path && screenshot?.path.includes(title) && screenshot?.takenAt)
60
+ .map(screenshot => screenshot.path)
61
+ : [];
62
+ const files = [...videos, ...screenshots];
63
+ let state;
64
+ switch (test.state) {
65
+ case 'passed':
66
+ state = constants_js_1.STATUS.PASSED;
67
+ break;
68
+ case 'failed':
69
+ state = constants_js_1.STATUS.FAILED;
70
+ break;
71
+ case 'skipped':
72
+ case 'pending':
73
+ default:
74
+ state = constants_js_1.STATUS.SKIPPED;
75
+ }
76
+ addSpecTestsPromises.push(client.addTestRun(state, {
77
+ title,
78
+ time,
79
+ example,
80
+ error: formattedError,
81
+ files,
82
+ suite_title: suiteTitle,
83
+ test_id: testId,
84
+ suite_id: suiteId,
85
+ }));
86
+ }
87
+ await Promise.all(addSpecTestsPromises);
88
+ });
89
+ on('after:run', async (results) => {
90
+ const status = results.totalFailed ? constants_js_1.STATUS.FAILED : constants_js_1.STATUS.PASSED;
91
+ // @ts-ignore
92
+ await client.updateRunStatus(status);
93
+ });
107
94
  };
108
-
109
95
  module.exports = testomatioReporter;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JasmineReporter = void 0;
7
+ const client_js_1 = __importDefault(require("../../client.js"));
8
+ const utils_js_1 = require("../../utils/utils.js");
9
+ const constants_js_1 = require("../../constants.js");
10
+ class JasmineReporter {
11
+ constructor(options) {
12
+ this.testTimeMap = {};
13
+ this.client = new client_js_1.default({ apiKey: options?.apiKey });
14
+ this.client.createRun();
15
+ }
16
+ getDuration(test) {
17
+ if (this.testTimeMap[test.id]) {
18
+ return Date.now() - this.testTimeMap[test.id];
19
+ }
20
+ return 0;
21
+ }
22
+ specStarted(result) {
23
+ this.testTimeMap[result.id] = Date.now();
24
+ }
25
+ specDone(result) {
26
+ if (!this.client)
27
+ return;
28
+ const title = result.description;
29
+ const { status } = result;
30
+ let errorMessage = '';
31
+ for (let i = 0; i < result.failedExpectations.length; i += 1) {
32
+ errorMessage = `${errorMessage}Failure: ${result.failedExpectations[i].message}\n`;
33
+ errorMessage = `${errorMessage}\n ${result.failedExpectations[i].stack}`;
34
+ }
35
+ console.log(`${title} : ${constants_js_1.STATUS.PASSED}`);
36
+ console.log(errorMessage);
37
+ const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(title);
38
+ errorMessage = errorMessage.replace((0, utils_js_1.ansiRegExp)(), '');
39
+ this.client.addTestRun(status, {
40
+ error: result.failedExpectations[0],
41
+ message: errorMessage,
42
+ test_id: testId,
43
+ title,
44
+ time: this.getDuration(result),
45
+ });
46
+ }
47
+ jasmineDone(suiteInfo, done) {
48
+ if (!this.client)
49
+ return;
50
+ const { overallStatus } = suiteInfo;
51
+ const status = overallStatus === 'failed' ? constants_js_1.STATUS.FAILED : constants_js_1.STATUS.PASSED;
52
+ // @ts-ignore
53
+ this.client.updateRunStatus(status).then(() => done);
54
+ }
55
+ }
56
+ exports.JasmineReporter = JasmineReporter;
57
+ module.exports = JasmineReporter;
58
+
59
+ module.exports.JasmineReporter = JasmineReporter;
60
+
61
+ module.exports.JasmineReporter = JasmineReporter;
62
+
63
+ module.exports.exports = exports;