@testomatio/reporter 1.6.13 → 2.0.1-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 (142) hide show
  1. package/lib/adapter/codecept.d.ts +2 -0
  2. package/lib/adapter/codecept.js +295 -335
  3. package/lib/adapter/cucumber/current.d.ts +14 -0
  4. package/lib/adapter/cucumber/current.js +195 -203
  5. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  6. package/lib/adapter/cucumber/legacy.js +130 -155
  7. package/lib/adapter/cucumber.d.ts +2 -0
  8. package/lib/adapter/cucumber.js +5 -16
  9. package/lib/adapter/cypress-plugin/index.d.ts +2 -0
  10. package/lib/adapter/cypress-plugin/index.js +93 -105
  11. package/lib/adapter/jasmine.d.ts +11 -0
  12. package/lib/adapter/jasmine.js +54 -53
  13. package/lib/adapter/jest.d.ts +13 -0
  14. package/lib/adapter/jest.js +97 -99
  15. package/lib/adapter/mocha.d.ts +2 -0
  16. package/lib/adapter/mocha.js +112 -140
  17. package/lib/adapter/playwright.d.ts +14 -0
  18. package/lib/adapter/playwright.js +195 -231
  19. package/lib/adapter/vitest.d.ts +35 -0
  20. package/lib/adapter/vitest.js +150 -149
  21. package/lib/adapter/webdriver.d.ts +24 -0
  22. package/lib/adapter/webdriver.js +134 -119
  23. package/lib/bin/cli.d.ts +2 -0
  24. package/lib/bin/cli.js +164 -211
  25. package/lib/bin/reportXml.d.ts +2 -0
  26. package/lib/bin/reportXml.js +49 -52
  27. package/lib/bin/startTest.d.ts +2 -0
  28. package/lib/bin/startTest.js +82 -95
  29. package/lib/bin/uploadArtifacts.d.ts +2 -0
  30. package/lib/bin/uploadArtifacts.js +55 -61
  31. package/lib/client.d.ts +76 -0
  32. package/lib/client.js +411 -465
  33. package/lib/config.d.ts +1 -0
  34. package/lib/config.js +16 -21
  35. package/lib/constants.d.ts +25 -0
  36. package/lib/constants.js +50 -44
  37. package/lib/data-storage.d.ts +34 -0
  38. package/lib/data-storage.js +206 -188
  39. package/lib/junit-adapter/adapter.d.ts +9 -0
  40. package/lib/junit-adapter/adapter.js +17 -20
  41. package/lib/junit-adapter/csharp.d.ts +4 -0
  42. package/lib/junit-adapter/csharp.js +18 -14
  43. package/lib/junit-adapter/index.d.ts +3 -0
  44. package/lib/junit-adapter/index.js +27 -25
  45. package/lib/junit-adapter/java.d.ts +5 -0
  46. package/lib/junit-adapter/java.js +41 -53
  47. package/lib/junit-adapter/javascript.d.ts +4 -0
  48. package/lib/junit-adapter/javascript.js +30 -27
  49. package/lib/junit-adapter/python.d.ts +5 -0
  50. package/lib/junit-adapter/python.js +38 -37
  51. package/lib/junit-adapter/ruby.d.ts +4 -0
  52. package/lib/junit-adapter/ruby.js +11 -8
  53. package/lib/output.d.ts +11 -0
  54. package/lib/output.js +44 -52
  55. package/lib/package.json +3 -0
  56. package/lib/pipe/bitbucket.d.ts +23 -0
  57. package/lib/pipe/bitbucket.js +210 -229
  58. package/lib/pipe/csv.d.ts +47 -0
  59. package/lib/pipe/csv.js +113 -126
  60. package/lib/pipe/debug.d.ts +29 -0
  61. package/lib/pipe/debug.js +104 -99
  62. package/lib/pipe/github.d.ts +30 -0
  63. package/lib/pipe/github.js +186 -213
  64. package/lib/pipe/gitlab.d.ts +23 -0
  65. package/lib/pipe/gitlab.js +166 -207
  66. package/lib/pipe/html.d.ts +34 -0
  67. package/lib/pipe/html.js +260 -319
  68. package/lib/pipe/index.d.ts +1 -0
  69. package/lib/pipe/index.js +84 -66
  70. package/lib/pipe/testomatio.d.ts +70 -0
  71. package/lib/pipe/testomatio.js +413 -462
  72. package/lib/reporter-functions.d.ts +34 -0
  73. package/lib/reporter-functions.js +28 -26
  74. package/lib/reporter.d.ts +232 -0
  75. package/lib/reporter.js +34 -29
  76. package/lib/services/artifacts.d.ts +33 -0
  77. package/lib/services/artifacts.js +55 -51
  78. package/lib/services/index.d.ts +9 -0
  79. package/lib/services/index.js +14 -12
  80. package/lib/services/key-values.d.ts +27 -0
  81. package/lib/services/key-values.js +56 -53
  82. package/lib/services/logger.d.ts +64 -0
  83. package/lib/services/logger.js +227 -245
  84. package/lib/template/testomatio.hbs +651 -1366
  85. package/lib/uploader.d.ts +60 -0
  86. package/lib/uploader.js +291 -360
  87. package/lib/utils/pipe_utils.d.ts +41 -0
  88. package/lib/utils/pipe_utils.js +89 -85
  89. package/lib/utils/utils.d.ts +45 -0
  90. package/lib/utils/utils.js +347 -307
  91. package/lib/xmlReader.d.ts +92 -0
  92. package/lib/xmlReader.js +490 -529
  93. package/package.json +57 -15
  94. package/src/adapter/codecept.js +375 -0
  95. package/src/adapter/cucumber/current.js +228 -0
  96. package/src/adapter/cucumber/legacy.js +158 -0
  97. package/src/adapter/cucumber.js +4 -0
  98. package/src/adapter/cypress-plugin/index.js +112 -0
  99. package/src/adapter/jasmine.js +60 -0
  100. package/src/adapter/jest.js +107 -0
  101. package/src/adapter/mocha.cjs +2 -0
  102. package/src/adapter/mocha.js +157 -0
  103. package/src/adapter/playwright.js +250 -0
  104. package/src/adapter/vitest.js +183 -0
  105. package/src/adapter/webdriver.js +142 -0
  106. package/src/bin/cli.js +280 -0
  107. package/src/bin/reportXml.js +74 -0
  108. package/src/bin/startTest.js +123 -0
  109. package/src/bin/uploadArtifacts.js +90 -0
  110. package/src/client.js +504 -0
  111. package/src/config.js +30 -0
  112. package/src/constants.js +53 -0
  113. package/src/data-storage.js +204 -0
  114. package/src/junit-adapter/adapter.js +23 -0
  115. package/src/junit-adapter/csharp.js +16 -0
  116. package/src/junit-adapter/index.js +28 -0
  117. package/src/junit-adapter/java.js +58 -0
  118. package/src/junit-adapter/javascript.js +31 -0
  119. package/src/junit-adapter/python.js +42 -0
  120. package/src/junit-adapter/ruby.js +10 -0
  121. package/src/output.js +57 -0
  122. package/src/pipe/bitbucket.js +254 -0
  123. package/src/pipe/csv.js +140 -0
  124. package/src/pipe/debug.js +104 -0
  125. package/src/pipe/github.js +233 -0
  126. package/src/pipe/gitlab.js +229 -0
  127. package/src/pipe/html.js +374 -0
  128. package/src/pipe/index.js +71 -0
  129. package/src/pipe/testomatio.js +503 -0
  130. package/src/reporter-functions.js +55 -0
  131. package/src/reporter.cjs_decprecated +21 -0
  132. package/src/reporter.js +33 -0
  133. package/src/services/artifacts.js +59 -0
  134. package/src/services/index.js +13 -0
  135. package/src/services/key-values.js +59 -0
  136. package/src/services/logger.js +316 -0
  137. package/src/template/emptyData.svg +23 -0
  138. package/src/template/testomatio.hbs +706 -0
  139. package/src/uploader.js +371 -0
  140. package/src/utils/pipe_utils.js +119 -0
  141. package/src/utils/utils.js +383 -0
  142. package/src/xmlReader.js +562 -0
@@ -0,0 +1,13 @@
1
+ export class JestReporter {
2
+ constructor(globalConfig: any, options: any);
3
+ _globalConfig: any;
4
+ _options: any;
5
+ client: TestomatClient;
6
+ onRunStart(): void;
7
+ onTestStart(testFile: any): void;
8
+ onTestCaseStart(test: any, testCase: any): void;
9
+ onTestResult(test: any, testResult: any): void;
10
+ onRunComplete(contexts: any, results: any): void;
11
+ }
12
+ export default JestReporter;
13
+ import TestomatClient from '../client.js';
@@ -1,105 +1,103 @@
1
- const chalk = require('chalk');
2
- const TestomatClient = require('../client');
3
- const { STATUS, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
4
- const { getTestomatIdFromTestTitle, ansiRegExp, fileSystem } = require('../utils/utils');
5
- const { services } = require('../services');
6
- const debug = require('debug')('@testomatio/reporter:adapter-jest');
7
- const path = require('path');
8
-
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.JestReporter = void 0;
7
+ const picocolors_1 = __importDefault(require("picocolors"));
8
+ const client_js_1 = __importDefault(require("../client.js"));
9
+ const constants_js_1 = require("../constants.js");
10
+ const utils_js_1 = require("../utils/utils.js");
11
+ const index_js_1 = require("../services/index.js");
12
+ const path_1 = __importDefault(require("path"));
13
+ const debug_1 = __importDefault(require("debug"));
14
+ const debug = (0, debug_1.default)('@testomatio/reporter:adapter-jest');
9
15
  class JestReporter {
10
- constructor(globalConfig, options) {
11
- this._globalConfig = globalConfig;
12
- this._options = options;
13
-
14
- this.client = new TestomatClient({ apiKey: options?.apiKey });
15
- this.client.createRun();
16
- }
17
-
18
- onRunStart() {
19
- // clear tmp dir
20
- fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
21
- }
22
-
23
- // start of test file (including beforeAll)
24
- onTestStart(testFile) {
25
- debug('Start running test file:', testFile.path);
26
- services.setContext(testFile.path);
27
- }
28
-
29
- // start of the test (including beforeEach)
30
- onTestCaseStart(test, testCase) {
31
- debug('Start running test:', testCase.fullName);
32
- services.setContext(testCase.fullName);
33
- }
34
-
35
- // end of test file! (there is also onTestCaseResult listener)
36
- onTestResult(test, testResult) {
37
- if (!this.client) return;
38
-
39
- const { testResults } = testResult;
40
- for (const result of testResults) {
41
- let error;
42
- let steps;
43
- const { status, title, duration, failureMessages } = result;
44
- if (failureMessages[0]) {
45
- let errorMessage = failureMessages[0].replace(ansiRegExp(), '');
46
- errorMessage = errorMessage.split('\n')[0];
47
- error = new Error(errorMessage);
48
- steps = failureMessages[0];
49
- }
50
- const testId = getTestomatIdFromTestTitle(title);
51
-
52
- // suite titles from most outer to most inner, separated by space
53
- let fullSuiteTitle = testResult.ancestorTitles?.join(' ');
54
- // if no suite titles, use file name
55
- if (!fullSuiteTitle && testResult.testFilePath) fullSuiteTitle = path.basename(testResult.testFilePath);
56
-
57
- const logs = getTestLogs(result);
58
- const artifacts = services.artifacts.get(result.fullName);
59
- const keyValues = services.keyValues.get(result.fullName);
60
-
61
- const deducedStatus = status === 'pending' ? 'skipped' : status;
62
- // In jest if test is not matched with test name pattern it is considered as skipped.
63
- // So adding a check if it is skipped for real or because of test pattern
64
- if (!this._globalConfig.testNamePattern || deducedStatus !== 'skipped') {
65
- this.client.addTestRun(deducedStatus, {
66
- test_id: testId,
67
- suite_title: fullSuiteTitle,
68
- error,
69
- steps,
70
- title,
71
- time: duration,
72
- logs,
73
- manuallyAttachedArtifacts: artifacts,
74
- meta: keyValues,
75
- });
76
- }
16
+ constructor(globalConfig, options) {
17
+ this._globalConfig = globalConfig;
18
+ this._options = options;
19
+ this.client = new client_js_1.default({ apiKey: options?.apiKey });
20
+ this.client.createRun();
21
+ }
22
+ onRunStart() {
23
+ // clear tmp dir
24
+ utils_js_1.fileSystem.clearDir(constants_js_1.TESTOMAT_TMP_STORAGE_DIR);
25
+ }
26
+ // start of test file (including beforeAll)
27
+ onTestStart(testFile) {
28
+ debug('Start running test file:', testFile.path);
29
+ index_js_1.services.setContext(testFile.path);
30
+ }
31
+ // start of the test (including beforeEach)
32
+ onTestCaseStart(test, testCase) {
33
+ debug('Start running test:', testCase.fullName);
34
+ index_js_1.services.setContext(testCase.fullName);
35
+ }
36
+ // end of test file! (there is also onTestCaseResult listener)
37
+ onTestResult(test, testResult) {
38
+ if (!this.client)
39
+ return;
40
+ const { testResults } = testResult;
41
+ for (const result of testResults) {
42
+ let error;
43
+ let steps;
44
+ const { status, title, duration, failureMessages } = result;
45
+ if (failureMessages[0]) {
46
+ let errorMessage = failureMessages[0].replace((0, utils_js_1.ansiRegExp)(), '');
47
+ errorMessage = errorMessage.split('\n')[0];
48
+ error = new Error(errorMessage);
49
+ steps = failureMessages[0];
50
+ }
51
+ const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(title);
52
+ // suite titles from most outer to most inner, separated by space
53
+ let fullSuiteTitle = testResult.ancestorTitles?.join(' ');
54
+ // if no suite titles, use file name
55
+ if (!fullSuiteTitle && testResult.testFilePath)
56
+ fullSuiteTitle = path_1.default.basename(testResult.testFilePath);
57
+ const logs = getTestLogs(result);
58
+ const artifacts = index_js_1.services.artifacts.get(result.fullName);
59
+ const keyValues = index_js_1.services.keyValues.get(result.fullName);
60
+ const deducedStatus = status === 'pending' ? 'skipped' : status;
61
+ // In jest if test is not matched with test name pattern it is considered as skipped.
62
+ // So adding a check if it is skipped for real or because of test pattern
63
+ if (!this._globalConfig.testNamePattern || deducedStatus !== 'skipped') {
64
+ this.client.addTestRun(deducedStatus, {
65
+ test_id: testId,
66
+ suite_title: fullSuiteTitle,
67
+ error,
68
+ steps,
69
+ title,
70
+ time: duration,
71
+ logs,
72
+ manuallyAttachedArtifacts: artifacts,
73
+ meta: keyValues,
74
+ });
75
+ }
76
+ }
77
+ }
78
+ onRunComplete(contexts, results) {
79
+ if (!this.client)
80
+ return;
81
+ const { numFailedTests } = results;
82
+ const status = numFailedTests === 0 ? 'passed' : 'failed';
83
+ this.client.updateRunStatus(status);
77
84
  }
78
- }
79
-
80
- onRunComplete(contexts, results) {
81
- if (!this.client) return;
82
-
83
- const { numFailedTests } = results;
84
- const status = numFailedTests === 0 ? STATUS.PASSED : STATUS.FAILED;
85
- this.client.updateRunStatus(status);
86
- }
87
85
  }
88
-
86
+ exports.JestReporter = JestReporter;
89
87
  function getTestLogs(testResult) {
90
- const suiteLogsArr = services.logger.getLogs(testResult.testFilePath);
91
- const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
92
- const testLogsArr = services.logger.getLogs(testResult.fullName);
93
- const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
94
-
95
- let logs = '';
96
- if (suiteLogs) {
97
- logs += `${chalk.bold('\t--- Suite ---')}\n${suiteLogs}`;
98
- }
99
- if (testLogs) {
100
- logs += `\n${chalk.bold('\t--- Test ---')}\n${testLogs}`;
101
- }
102
- return logs;
88
+ const suiteLogsArr = index_js_1.services.logger.getLogs(testResult.testFilePath);
89
+ const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
90
+ const testLogsArr = index_js_1.services.logger.getLogs(testResult.fullName);
91
+ const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
92
+ let logs = '';
93
+ if (suiteLogs) {
94
+ logs += `${picocolors_1.default.bold('\t--- Suite ---')}\n${suiteLogs}`;
95
+ }
96
+ if (testLogs) {
97
+ logs += `\n${picocolors_1.default.bold('\t--- Test ---')}\n${testLogs}`;
98
+ }
99
+ return logs;
103
100
  }
104
-
105
101
  module.exports = JestReporter;
102
+
103
+ module.exports.JestReporter = JestReporter;
@@ -0,0 +1,2 @@
1
+ export default MochaReporter;
2
+ declare function MochaReporter(runner: any, opts: any): void;
@@ -1,154 +1,126 @@
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 });
1
6
  // eslint-disable-next-line global-require, import/no-extraneous-dependencies
2
- const Mocha = require('mocha');
3
- const chalk = require('chalk');
4
- const TestomatClient = require('../client');
5
- const { STATUS, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
6
- const { getTestomatIdFromTestTitle, fileSystem } = require('../utils/utils');
7
- const config = require('../config');
8
- const { services } = require('../services');
9
-
10
- const {
11
- EVENT_RUN_BEGIN,
12
- EVENT_RUN_END,
13
- EVENT_TEST_FAIL,
14
- EVENT_TEST_PASS,
15
- EVENT_TEST_PENDING,
16
- EVENT_SUITE_BEGIN,
17
- EVENT_SUITE_END,
18
- EVENT_TEST_BEGIN,
19
- EVENT_TEST_END,
20
- } = Mocha.Runner.constants;
21
-
7
+ const mocha_1 = __importDefault(require("mocha"));
8
+ const client_js_1 = __importDefault(require("../client.js"));
9
+ const constants_js_1 = require("../constants.js");
10
+ const utils_js_1 = require("../utils/utils.js");
11
+ const config_js_1 = require("../config.js");
12
+ const index_js_1 = require("../services/index.js");
13
+ const picocolors_1 = __importDefault(require("picocolors"));
14
+ const { EVENT_RUN_BEGIN, EVENT_RUN_END, EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, EVENT_SUITE_BEGIN, EVENT_SUITE_END, EVENT_TEST_BEGIN, EVENT_TEST_END, } = mocha_1.default.Runner.constants;
22
15
  function MochaReporter(runner, opts) {
23
- Mocha.reporters.Base.call(this, runner);
24
- let passes = 0;
25
- let failures = 0;
26
- let skipped = 0;
27
-
28
- const apiKey = opts?.reporterOptions?.apiKey || config.TESTOMATIO;
29
-
30
- const client = new TestomatClient({ apiKey });
31
-
32
- runner.on(EVENT_RUN_BEGIN, () => {
33
- client.createRun();
34
-
35
- // clear dir with artifacts/logs
36
- fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
37
- });
38
-
39
- runner.on(EVENT_SUITE_BEGIN, async suite => {
40
- services.setContext(suite.fullTitle());
41
- });
42
-
43
- runner.on(EVENT_SUITE_END, async () => {
44
- services.setContext(null);
45
- });
46
-
47
- runner.on(EVENT_TEST_BEGIN, async test => {
48
- services.setContext(test.fullTitle());
49
- });
50
-
51
- runner.on(EVENT_TEST_END, async () => {
52
- services.setContext(null);
53
- });
54
-
55
- runner.on(EVENT_TEST_PASS, async test => {
56
- passes += 1;
57
-
58
- console.log(chalk.bold.green('✔'), test.fullTitle());
59
- const testId = getTestomatIdFromTestTitle(test.title);
60
-
61
- const logs = getTestLogs(test);
62
- const artifacts = services.artifacts.get(test.fullTitle());
63
- const keyValues = services.keyValues.get(test.fullTitle());
64
-
65
- client.addTestRun(STATUS.PASSED, {
66
- test_id: testId,
67
- suite_title: getSuiteTitle(test),
68
- title: getTestName(test),
69
- code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
70
- file: getFile(test),
71
- time: test.duration,
72
- logs,
73
- manuallyAttachedArtifacts: artifacts,
74
- meta: keyValues,
16
+ mocha_1.default.reporters.Base.call(this, runner);
17
+ let passes = 0;
18
+ let failures = 0;
19
+ let skipped = 0;
20
+ // let artifactStore;
21
+ const apiKey = opts?.reporterOptions?.apiKey || config_js_1.config.TESTOMATIO;
22
+ const client = new client_js_1.default({ apiKey });
23
+ runner.on(EVENT_RUN_BEGIN, () => {
24
+ client.createRun();
25
+ // clear dir with artifacts/logs
26
+ utils_js_1.fileSystem.clearDir(constants_js_1.TESTOMAT_TMP_STORAGE_DIR);
75
27
  });
76
- });
77
-
78
- runner.on(EVENT_TEST_PENDING, test => {
79
- skipped += 1;
80
- console.log('skip: %s', test.fullTitle());
81
- const testId = getTestomatIdFromTestTitle(test.title);
82
- client.addTestRun(STATUS.SKIPPED, {
83
- title: getTestName(test),
84
- suite_title: getSuiteTitle(test),
85
- code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
86
- file: getFile(test),
87
- test_id: testId,
88
- time: test.duration,
28
+ runner.on(EVENT_SUITE_BEGIN, async (suite) => {
29
+ index_js_1.services.setContext(suite.fullTitle());
89
30
  });
90
- });
91
-
92
- runner.on(EVENT_TEST_FAIL, async (test, err) => {
93
- failures += 1;
94
- console.log(chalk.bold.red('✖'), test.fullTitle(), chalk.gray(err.message));
95
- const testId = getTestomatIdFromTestTitle(test.title);
96
-
97
- const logs = getTestLogs(test);
98
-
99
- client.addTestRun(STATUS.FAILED, {
100
- error: err,
101
- suite_title: getSuiteTitle(test),
102
- file: getFile(test),
103
- test_id: testId,
104
- title: getTestName(test),
105
- code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
106
- time: test.duration,
107
- logs,
31
+ runner.on(EVENT_SUITE_END, async () => {
32
+ index_js_1.services.setContext(null);
33
+ });
34
+ runner.on(EVENT_TEST_BEGIN, async (test) => {
35
+ index_js_1.services.setContext(test.fullTitle());
36
+ });
37
+ runner.on(EVENT_TEST_END, async () => {
38
+ index_js_1.services.setContext(null);
39
+ });
40
+ runner.on(EVENT_TEST_PASS, async (test) => {
41
+ passes += 1;
42
+ console.log(picocolors_1.default.bold(picocolors_1.default.green('✔')), test.fullTitle());
43
+ const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
44
+ const logs = getTestLogs(test);
45
+ const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
46
+ const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
47
+ client.addTestRun(constants_js_1.STATUS.PASSED, {
48
+ test_id: testId,
49
+ suite_title: getSuiteTitle(test),
50
+ title: getTestName(test),
51
+ code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
52
+ file: getFile(test),
53
+ time: test.duration,
54
+ logs,
55
+ manuallyAttachedArtifacts: artifacts,
56
+ meta: keyValues,
57
+ });
58
+ });
59
+ runner.on(EVENT_TEST_PENDING, test => {
60
+ skipped += 1;
61
+ console.log('skip: %s', test.fullTitle());
62
+ const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
63
+ client.addTestRun(constants_js_1.STATUS.SKIPPED, {
64
+ title: getTestName(test),
65
+ suite_title: getSuiteTitle(test),
66
+ code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
67
+ file: getFile(test),
68
+ test_id: testId,
69
+ time: test.duration,
70
+ });
71
+ });
72
+ runner.on(EVENT_TEST_FAIL, async (test, err) => {
73
+ failures += 1;
74
+ console.log(picocolors_1.default.bold(picocolors_1.default.red('✖')), test.fullTitle(), picocolors_1.default.gray(err.message));
75
+ const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
76
+ const logs = getTestLogs(test);
77
+ client.addTestRun(constants_js_1.STATUS.FAILED, {
78
+ error: err,
79
+ suite_title: getSuiteTitle(test),
80
+ file: getFile(test),
81
+ test_id: testId,
82
+ title: getTestName(test),
83
+ code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
84
+ time: test.duration,
85
+ logs,
86
+ });
87
+ });
88
+ runner.on(EVENT_RUN_END, () => {
89
+ const status = failures === 0 ? constants_js_1.STATUS.PASSED : constants_js_1.STATUS.FAILED;
90
+ console.log(picocolors_1.default.bold(status), `${passes} passed, ${failures} failed, ${skipped} skipped`);
91
+ // @ts-ignore
92
+ client.updateRunStatus(status);
108
93
  });
109
- });
110
-
111
- runner.on(EVENT_RUN_END, () => {
112
- const status = failures === 0 ? STATUS.PASSED : STATUS.FAILED;
113
- console.log(chalk.bold(status), `${passes} passed, ${failures} failed, ${skipped} skipped`);
114
- client.updateRunStatus(status);
115
- });
116
94
  }
117
-
118
95
  function getTestLogs(test) {
119
- const suiteLogsArr = services.logger.getLogs(test.parent.fullTitle());
120
- const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
121
- const testLogsArr = services.logger.getLogs(test.fullTitle());
122
- const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
123
-
124
- let logs = '';
125
- if (suiteLogs) {
126
- logs += `${chalk.bold('\t--- BeforeSuite ---')}\n${suiteLogs}`;
127
- }
128
- if (testLogs) {
129
- logs += `\n${chalk.bold('\t--- Test ---')}\n${testLogs}`;
130
- }
131
- return logs;
96
+ const suiteLogsArr = index_js_1.services.logger.getLogs(test.parent.fullTitle());
97
+ const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
98
+ const testLogsArr = index_js_1.services.logger.getLogs(test.fullTitle());
99
+ const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
100
+ let logs = '';
101
+ if (suiteLogs) {
102
+ logs += `${picocolors_1.default.bold('\t--- BeforeSuite ---')}\n${suiteLogs}`;
103
+ }
104
+ if (testLogs) {
105
+ logs += `\n${picocolors_1.default.bold('\t--- Test ---')}\n${testLogs}`;
106
+ }
107
+ return logs;
132
108
  }
133
-
134
- // To have this reporter "extend" a built-in reporter uncomment the following line:
135
- Mocha.utils.inherits(MochaReporter, Mocha.reporters.Spec);
136
-
137
- module.exports = MochaReporter;
138
-
139
109
  function getSuiteTitle(test, pathArr = []) {
140
- if (test.parent.parent) getSuiteTitle(test.parent, pathArr);
141
-
142
- pathArr.push(test.parent.title);
143
-
144
- return pathArr.filter(t => !!t)[0];
110
+ if (test.parent.parent)
111
+ getSuiteTitle(test.parent, pathArr);
112
+ pathArr.push(test.parent.title);
113
+ return pathArr.filter(t => !!t)[0];
145
114
  }
146
-
147
115
  function getFile(test) {
148
- return test.parent.file?.replace(process.cwd(), '');
116
+ return test.parent.file?.replace(process.cwd(), '');
149
117
  }
150
-
151
118
  function getTestName(test) {
152
- if (process.env.TESTOMATIO_CREATE === 'fulltitle') return test.fullTitle();
153
- return test.title;
119
+ if (process.env.TESTOMATIO_CREATE === 'fulltitle')
120
+ return test.fullTitle();
121
+ return test.title;
154
122
  }
123
+ // To have this reporter "extend" a built-in reporter uncomment the following line:
124
+ // @ts-ignore
125
+ mocha_1.default.utils.inherits(MochaReporter, mocha_1.default.reporters.Spec);
126
+ module.exports = MochaReporter;
@@ -0,0 +1,14 @@
1
+ export default PlaywrightReporter;
2
+ declare class PlaywrightReporter {
3
+ constructor(config?: {});
4
+ client: TestomatioClient;
5
+ uploads: any[];
6
+ onBegin(config: any, suite: any): void;
7
+ suite: any;
8
+ config: any;
9
+ onTestBegin(testInfo: any): void;
10
+ onTestEnd(test: any, result: any): void;
11
+ onEnd(result: any): Promise<void>;
12
+ #private;
13
+ }
14
+ import TestomatioClient from '../client.js';