@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
@@ -0,0 +1,245 @@
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.upload = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const client_s3_1 = require("@aws-sdk/client-s3");
9
+ const lib_storage_1 = require("@aws-sdk/lib-storage");
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const util_1 = __importDefault(require("util"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const promise_retry_1 = __importDefault(require("promise-retry"));
14
+ const picocolors_1 = __importDefault(require("picocolors"));
15
+ const crypto_1 = require("crypto");
16
+ const constants_js_1 = require("./constants.js");
17
+ const readFile = util_1.default.promisify(fs_1.default.readFile);
18
+ const stat = util_1.default.promisify(fs_1.default.stat);
19
+ const debug = (0, debug_1.default)('@testomatio/reporter:file-uploader');
20
+ const keys = [
21
+ 'S3_ENDPOINT',
22
+ 'S3_REGION',
23
+ 'S3_BUCKET',
24
+ 'S3_ACCESS_KEY_ID',
25
+ 'S3_SECRET_ACCESS_KEY',
26
+ 'S3_SESSION_TOKEN',
27
+ 'TESTOMATIO_DISABLE_ARTIFACTS',
28
+ 'TESTOMATIO_PRIVATE_ARTIFACTS',
29
+ 'S3_FORCE_PATH_STYLE',
30
+ ];
31
+ let config;
32
+ function resetConfig() {
33
+ config = undefined;
34
+ isEnabled = undefined;
35
+ }
36
+ function getConfig() {
37
+ if (config)
38
+ return config;
39
+ config = keys.reduce((acc, key) => {
40
+ acc[key] = process.env[key];
41
+ return acc;
42
+ }, {});
43
+ return config;
44
+ }
45
+ function getMaskedConfig() {
46
+ return Object.fromEntries(Object.entries(getConfig()).map(([key, value]) => [
47
+ key,
48
+ key === 'S3_SECRET_ACCESS_KEY' || key === 'S3_ACCESS_KEY_ID' ? '***' : value,
49
+ ]));
50
+ }
51
+ let isEnabled;
52
+ const isArtifactsEnabled = () => {
53
+ if (isEnabled !== undefined)
54
+ return isEnabled;
55
+ const { S3_BUCKET, TESTOMATIO_DISABLE_ARTIFACTS } = getConfig();
56
+ isEnabled = !!(S3_BUCKET && !TESTOMATIO_DISABLE_ARTIFACTS);
57
+ debug(`Upload is ${isEnabled ? 'enabled' : 'disabled'}`);
58
+ return isEnabled;
59
+ };
60
+ const _getFileExtBase64 = str => {
61
+ const type = str.charAt(0);
62
+ return ({
63
+ '/': '.jpg',
64
+ i: '.png',
65
+ R: '.gif',
66
+ U: '.webp',
67
+ }[type] || '');
68
+ };
69
+ const _getS3Config = () => {
70
+ const { S3_REGION, S3_SESSION_TOKEN, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_FORCE_PATH_STYLE, S3_ENDPOINT } = getConfig();
71
+ const cfg = {
72
+ region: S3_REGION,
73
+ credentials: {
74
+ accessKeyId: S3_ACCESS_KEY_ID,
75
+ secretAccessKey: S3_SECRET_ACCESS_KEY,
76
+ s3ForcePathStyle: S3_FORCE_PATH_STYLE,
77
+ },
78
+ };
79
+ if (S3_SESSION_TOKEN) {
80
+ cfg.credentials.sessionToken = S3_SESSION_TOKEN;
81
+ }
82
+ if (S3_ENDPOINT) {
83
+ cfg.endpoint = S3_ENDPOINT;
84
+ }
85
+ return cfg;
86
+ };
87
+ const uploadUsingS3 = async (filePath, runId) => {
88
+ let ContentType;
89
+ let Key;
90
+ if (typeof filePath === 'object') {
91
+ ContentType = filePath?.type;
92
+ filePath = filePath?.path;
93
+ Key = filePath?.name;
94
+ }
95
+ const { TESTOMATIO_PRIVATE_ARTIFACTS, S3_BUCKET } = getConfig();
96
+ try {
97
+ debug('S3 config', getMaskedConfig());
98
+ debug('Started upload', filePath, 'to ', S3_BUCKET);
99
+ // Verification that the file was actually created: 20 attempts of 0.5 second => 10sec
100
+ const isFileExist = await checkFileExists(filePath, 20, 500);
101
+ if (!isFileExist) {
102
+ console.error(picocolors_1.default.yellow(`Artifacts file ${filePath} does not exist. Skipping...`));
103
+ return;
104
+ }
105
+ debug('File: ', filePath, ' exists');
106
+ const fileData = await readFile(filePath);
107
+ Key = `${runId}/${(0, crypto_1.randomUUID)()}-${Key || path_1.default.basename(filePath)}`;
108
+ const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
109
+ if (!S3_BUCKET || !fileData) {
110
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold(picocolors_1.default.red(`Failed uploading '${Key}'. Please check S3 credentials`)), getMaskedConfig());
111
+ return;
112
+ }
113
+ const s3 = new client_s3_1.S3(_getS3Config());
114
+ /**
115
+ * @type {import('@aws-sdk/client-s3').PutObjectCommandInput}
116
+ */
117
+ const params = {
118
+ Bucket: S3_BUCKET,
119
+ Key,
120
+ Body: fileData,
121
+ ContentType,
122
+ ACL,
123
+ };
124
+ const out = new lib_storage_1.Upload({
125
+ client: s3,
126
+ params,
127
+ });
128
+ const link = await getS3LocationLink(out);
129
+ debug(`Succesfully uploaded ${filePath} => ${S3_BUCKET}/${Key} | URL: ${link}`);
130
+ return link;
131
+ }
132
+ catch (e) {
133
+ debug('S3 file uploading error: ', e);
134
+ console.log(constants_js_1.APP_PREFIX, `To ${picocolors_1.default.bold('disable')} artifact uploads set: TESTOMATIO_DISABLE_ARTIFACTS=1`);
135
+ if (!TESTOMATIO_PRIVATE_ARTIFACTS) {
136
+ console.log(constants_js_1.APP_PREFIX, `To enable ${picocolors_1.default.bold('PRIVATE')} uploads set: TESTOMATIO_PRIVATE_ARTIFACTS=1`);
137
+ }
138
+ else {
139
+ console.log(constants_js_1.APP_PREFIX, `To enable ${picocolors_1.default.bold('PUBLIC')} uploads remove TESTOMATIO_PRIVATE_ARTIFACTS env variable`);
140
+ }
141
+ console.log(constants_js_1.APP_PREFIX, '---------------');
142
+ }
143
+ };
144
+ const uploadUsingS3AsBuffer = async (buffer, fileName, runId) => {
145
+ const { S3_REGION, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_ENDPOINT, TESTOMATIO_PRIVATE_ARTIFACTS, S3_BUCKET } = getConfig();
146
+ const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
147
+ const fileExtension = _getFileExtBase64(buffer.toString('base64'));
148
+ const Key = `${runId}/${fileName}${fileExtension}`;
149
+ if (!S3_BUCKET || !buffer) {
150
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold(picocolors_1.default.red(`Failed uploading '${Key}'. Please check S3 credentials`)), {
151
+ accessKeyId: S3_ACCESS_KEY_ID,
152
+ secretAccessKey: S3_SECRET_ACCESS_KEY ? '**** (hidden) ***' : '(empty)',
153
+ region: S3_REGION,
154
+ bucket: S3_BUCKET,
155
+ acl: ACL,
156
+ endpoint: S3_ENDPOINT,
157
+ });
158
+ return;
159
+ }
160
+ const s3 = new client_s3_1.S3(_getS3Config());
161
+ try {
162
+ const out = new lib_storage_1.Upload({
163
+ client: s3,
164
+ params: {
165
+ Bucket: S3_BUCKET,
166
+ Key,
167
+ Body: buffer,
168
+ ACL,
169
+ },
170
+ });
171
+ return await getS3LocationLink(out);
172
+ }
173
+ catch (e) {
174
+ debug('S3 buffer uploading error: ', e);
175
+ console.log(constants_js_1.APP_PREFIX, `To ${picocolors_1.default.bold('disable')} artifact uploads set: TESTOMATIO_DISABLE_ARTIFACTS=1`);
176
+ if (!TESTOMATIO_PRIVATE_ARTIFACTS) {
177
+ console.log(constants_js_1.APP_PREFIX, `To enable ${picocolors_1.default.bold('PRIVATE')} uploads set: TESTOMATIO_PRIVATE_ARTIFACTS=1`);
178
+ }
179
+ else {
180
+ console.log(constants_js_1.APP_PREFIX, `To enable ${picocolors_1.default.bold('PUBLIC')} uploads remove TESTOMATIO_PRIVATE_ARTIFACTS env variable`);
181
+ }
182
+ console.log(constants_js_1.APP_PREFIX, '---------------');
183
+ }
184
+ };
185
+ const uploadFileByPath = async (filePath, runId) => {
186
+ try {
187
+ if (isArtifactsEnabled()) {
188
+ return uploadUsingS3(filePath, runId);
189
+ }
190
+ }
191
+ catch (e) {
192
+ debug(e);
193
+ console.error(picocolors_1.default.red('Error occurred while uploading artifacts! '), e);
194
+ }
195
+ };
196
+ const uploadFileAsBuffer = async (buffer, fileName, runId) => {
197
+ try {
198
+ if (isArtifactsEnabled()) {
199
+ return uploadUsingS3AsBuffer(buffer, fileName, runId);
200
+ }
201
+ }
202
+ catch (e) {
203
+ debug(e);
204
+ console.error(picocolors_1.default.red('Error occurred while uploading artifacts! '), e);
205
+ }
206
+ };
207
+ const checkFileExists = async (filePath, attempts = 5, intervalMs = 500) => {
208
+ const checkFile = async () => {
209
+ const fileStats = await stat(filePath);
210
+ if (fileStats.isFile()) {
211
+ return true;
212
+ }
213
+ throw new Error('File not found');
214
+ };
215
+ try {
216
+ await (0, promise_retry_1.default)({
217
+ retries: attempts,
218
+ minTimeout: intervalMs,
219
+ }, checkFile);
220
+ return true;
221
+ }
222
+ catch (err) {
223
+ console.error(picocolors_1.default.yellow(`File ${filePath} was not found or did not have time to be generated...`));
224
+ return false;
225
+ }
226
+ };
227
+ const getS3LocationLink = async (out) => {
228
+ const response = await out.done();
229
+ let s3Location = response?.Location;
230
+ if (!s3Location) {
231
+ // TODO: out: a fallback case - remove after deeper testing
232
+ s3Location = out?.singleUploadResult?.Location;
233
+ debug('Uploaded singleUploadResult.Location', s3Location);
234
+ if (!s3Location) {
235
+ throw new Error("Problems getting the S3 artifact's link. Please check S3 permissions!");
236
+ }
237
+ }
238
+ return s3Location;
239
+ };
240
+ exports.upload = {
241
+ uploadFileByPath,
242
+ uploadFileAsBuffer,
243
+ isArtifactsEnabled,
244
+ resetConfig,
245
+ };
@@ -1,23 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  class Adapter {
2
- constructor(opts) {
3
- this.opts = opts;
4
- }
5
-
6
- getFilePath(t) {
7
- return t.file;
8
- }
9
-
10
- formatTest(t) {
11
- return t;
12
- }
13
-
14
- formatStack(t) {
15
- return t.stack || '';
16
- }
17
-
18
- formatMessage(t) {
19
- return t.message;
20
- }
4
+ constructor(opts) {
5
+ this.opts = opts;
6
+ }
7
+ getFilePath(t) {
8
+ return t.file;
9
+ }
10
+ formatTest(t) {
11
+ return t;
12
+ }
13
+ formatStack(t) {
14
+ return t.stack || '';
15
+ }
16
+ formatMessage(t) {
17
+ return t.message;
18
+ }
21
19
  }
22
-
23
20
  module.exports = Adapter;
@@ -1,16 +1,20 @@
1
- const Adapter = require('./adapter');
2
-
3
- class CSharpAdapter extends Adapter {
4
- formatTest(t) {
5
- const title = t.title.replace(/\(.*?\)/, '').trim();
6
- const example = t.title.match(/\((.*?)\)/);
7
- if (example) t.example = { ...example[1].split(',') };
8
- const suite = t.suite_title.split('.');
9
- t.suite_title = suite.pop();
10
- t.file = suite.join('/');
11
- t.title = title.trim();
12
- return t;
13
- }
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 adapter_js_1 = __importDefault(require("./adapter.js"));
7
+ class CSharpAdapter extends adapter_js_1.default {
8
+ formatTest(t) {
9
+ const title = t.title.replace(/\(.*?\)/, '').trim();
10
+ const example = t.title.match(/\((.*?)\)/);
11
+ if (example)
12
+ t.example = { ...example[1].split(',') };
13
+ const suite = t.suite_title.split('.');
14
+ t.suite_title = suite.pop();
15
+ t.file = suite.join('/');
16
+ t.title = title.trim();
17
+ return t;
18
+ }
14
19
  }
15
-
16
20
  module.exports = CSharpAdapter;
@@ -1,28 +1,30 @@
1
- const Adapter = require('./adapter');
2
- const JavaScriptAdapter = require('./javascript');
3
- const JavaAdapter = require('./java');
4
- const PythonAdapter = require('./python');
5
- const RubyAdapter = require('./ruby');
6
- const CSharpAdapter = require('./csharp');
7
-
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 adapter_js_1 = __importDefault(require("./adapter.js"));
7
+ const javascript_js_1 = __importDefault(require("./javascript.js"));
8
+ const java_js_1 = __importDefault(require("./java.js"));
9
+ const python_js_1 = __importDefault(require("./python.js"));
10
+ const ruby_js_1 = __importDefault(require("./ruby.js"));
11
+ const csharp_js_1 = __importDefault(require("./csharp.js"));
8
12
  function AdapterFactory(lang, opts) {
9
- if (lang === 'java') {
10
- return new JavaAdapter(opts);
11
- }
12
- if (lang === 'js') {
13
- return new JavaScriptAdapter(opts);
14
- }
15
- if (lang === 'python') {
16
- return new PythonAdapter(opts);
17
- }
18
- if (lang === 'ruby') {
19
- return new RubyAdapter(opts);
20
- }
21
- if (lang === 'c#' || lang === 'csharp') {
22
- return new CSharpAdapter(opts);
23
- }
24
-
25
- return new Adapter(opts);
13
+ if (lang === 'java') {
14
+ return new java_js_1.default(opts);
15
+ }
16
+ if (lang === 'js') {
17
+ return new javascript_js_1.default(opts);
18
+ }
19
+ if (lang === 'python') {
20
+ return new python_js_1.default(opts);
21
+ }
22
+ if (lang === 'ruby') {
23
+ return new ruby_js_1.default(opts);
24
+ }
25
+ if (lang === 'c#' || lang === 'csharp') {
26
+ return new csharp_js_1.default(opts);
27
+ }
28
+ return new adapter_js_1.default(opts);
26
29
  }
27
-
28
30
  module.exports = AdapterFactory;
@@ -1,58 +1,46 @@
1
- const path = require('path');
2
- const Adapter = require('./adapter');
3
-
4
- class JavaAdapter extends Adapter {
5
- getFilePath(t) {
6
- const fileName = namespaceToFileName(t.suite_title);
7
- return this.opts.javaTests + path.sep + fileName;
8
- }
9
-
10
- formatTest(t) {
11
- const fileParts = t.suite_title.split('.');
12
-
13
- t.file = namespaceToFileName(t.suite_title);
14
- t.title = t.title.split('(')[0];
15
-
16
- // detect params
17
- const paramMatches = t.title.match(/\[(.*?)\]/g);
18
-
19
- if (paramMatches) {
20
- const params = paramMatches.map((_match, index) => `param${index + 1}`);
21
- if (params.length === 1) params[0] = 'param';
22
- let paramIndex = 0;
23
-
24
- t.title = t.title.replace(/: \[(.*?)\]/g, () => {
25
- if (params.length < 2) return `\${param}`;
26
- const paramName = params[paramIndex] || `param${paramIndex + 1}`;
27
- paramIndex++;
28
- return `\${${paramName}}`;
29
- });
30
- const example = {};
31
- paramMatches.forEach((match, index) => {
32
- example[params[index]] = match.replace(/[[\]]/g, '');
33
- });
34
- t.example = example;
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 path_1 = __importDefault(require("path"));
7
+ const adapter_js_1 = __importDefault(require("./adapter.js"));
8
+ class JavaAdapter extends adapter_js_1.default {
9
+ getFilePath(t) {
10
+ const fileName = namespaceToFileName(t.suite_title);
11
+ return this.opts.javaTests + path_1.default.sep + fileName;
12
+ }
13
+ formatTest(t) {
14
+ const fileParts = t.suite_title.split('.');
15
+ t.file = namespaceToFileName(t.suite_title);
16
+ t.title = t.title.split('(')[0];
17
+ // detect params
18
+ const paramMatches = t.title.match(/\[(.*?)\]/g);
19
+ if (paramMatches) {
20
+ const params = paramMatches.map((_match, index) => `param${index + 1}`);
21
+ if (params.length === 1)
22
+ params[0] = 'param';
23
+ let paramIndex = 0;
24
+ t.title = t.title.replace(/: \[(.*?)\]/g, () => {
25
+ if (params.length < 2)
26
+ return `\${param}`;
27
+ const paramName = params[paramIndex] || `param${paramIndex + 1}`;
28
+ paramIndex++;
29
+ return `\${${paramName}}`;
30
+ });
31
+ const example = {};
32
+ paramMatches.forEach((match, index) => {
33
+ example[params[index]] = match.replace(/[[\]]/g, '');
34
+ });
35
+ t.example = example;
36
+ }
37
+ t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
38
+ return t;
35
39
  }
36
-
37
- t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
38
- return t;
39
- }
40
-
41
- // formatStack(t) {
42
- // const stack = super.formatStack(t);
43
-
44
- // const file = t.suite_title.split('.');
45
-
46
- // const fileLine = `at .*${file[file.length - 1]}\.java:(\\d+)` // eslint-disable-line no-useless-escape
47
- // const regexp = new RegExp(fileLine,"g")
48
- // return stack.replace(regexp, `${this.opts.javaTests}${path.sep}${namespaceToFileName(t.suite_title)}:$1:`);
49
- // }
50
40
  }
51
-
52
41
  function namespaceToFileName(fileName) {
53
- const fileParts = fileName.split('.');
54
- fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
55
- return `${fileParts.join(path.sep)}.java`;
42
+ const fileParts = fileName.split('.');
43
+ fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
44
+ return `${fileParts.join(path_1.default.sep)}.java`;
56
45
  }
57
-
58
46
  module.exports = JavaAdapter;
@@ -1,30 +1,33 @@
1
- const createCallsiteRecord = require('callsite-record');
2
- const path = require('path');
3
- const Adapter = require('./adapter');
4
-
5
- class JavaScriptAdapter extends Adapter {
6
- formatStack(t) {
7
- let stack = super.formatStack(t);
8
-
9
- try {
10
- const error = new Error(stack.split('\n')[0]);
11
- error.stack = stack;
12
- const record = createCallsiteRecord({
13
- forError: error,
14
- });
15
- if (record && !record.filename.startsWith('http')) {
16
- stack += record.renderSync({
17
- stackFilter: frame =>
18
- frame.getFileName().indexOf(path.sep) > -1 &&
19
- frame.getFileName().indexOf('node_modules') < 0 &&
20
- frame.getFileName().indexOf('internal') < 0,
21
- });
22
- }
23
- return stack;
24
- } catch (err) {
25
- return stack;
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 callsite_record_1 = __importDefault(require("callsite-record"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const adapter_js_1 = __importDefault(require("./adapter.js"));
9
+ class JavaScriptAdapter extends adapter_js_1.default {
10
+ formatStack(t) {
11
+ let stack = super.formatStack(t);
12
+ try {
13
+ const error = new Error(stack.split('\n')[0]);
14
+ error.stack = stack;
15
+ const record = (0, callsite_record_1.default)({
16
+ forError: error,
17
+ });
18
+ // @ts-ignore
19
+ if (record && !record.filename.startsWith('http')) {
20
+ stack += record.renderSync({
21
+ stackFilter: frame => frame.fileName?.indexOf(path_1.default.sep) > -1 &&
22
+ frame.fileName?.indexOf('node_modules') < 0 &&
23
+ frame.fileName?.indexOf('internal') < 0,
24
+ });
25
+ }
26
+ return stack;
27
+ }
28
+ catch (err) {
29
+ return stack;
30
+ }
26
31
  }
27
- }
28
32
  }
29
-
30
33
  module.exports = JavaScriptAdapter;
@@ -1,42 +1,43 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
- const Adapter = require('./adapter');
4
-
5
- class PythonAdapter extends Adapter {
6
- getFilePath(t) {
7
- let fileName = namespaceToFileName(t.suite_title, { checkFile: true });
8
- if (!fileName) fileName = namespaceToFileName(t.suite_title, { checkFile: false });
9
- return fileName;
10
- }
11
-
12
- formatTest(t) {
13
- const fileParts = t.suite_title.split('.');
14
- const example = t.title.match(/\[(.*)\]/)?.[1];
15
- if (example) t.example = { '#': example };
16
-
17
- t.file = namespaceToFileName(t.suite_title);
18
- t.title = t.title.split('[')[0];
19
- t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
20
- return t;
21
- }
22
-
23
- formatMessage(t) {
24
- return t.message.split('&#10;')[0];
25
- }
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 path_1 = __importDefault(require("path"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const adapter_js_1 = __importDefault(require("./adapter.js"));
9
+ class PythonAdapter extends adapter_js_1.default {
10
+ getFilePath(t) {
11
+ let fileName = namespaceToFileName(t.suite_title, { checkFile: true });
12
+ if (!fileName)
13
+ fileName = namespaceToFileName(t.suite_title, { checkFile: false });
14
+ return fileName;
15
+ }
16
+ formatTest(t) {
17
+ const fileParts = t.suite_title.split('.');
18
+ const example = t.title.match(/\[(.*)\]/)?.[1];
19
+ if (example)
20
+ t.example = { '#': example };
21
+ t.file = namespaceToFileName(t.suite_title);
22
+ t.title = t.title.split('[')[0];
23
+ t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
24
+ return t;
25
+ }
26
+ formatMessage(t) {
27
+ return t.message.split('&#10;')[0];
28
+ }
26
29
  }
27
-
28
30
  function namespaceToFileName(fileName, opts = {}) {
29
- const fileParts = fileName.split('.');
30
-
31
- while (fileParts.length > 0) {
32
- const file = `${fileParts.join(path.sep)}.py`;
33
- if (!opts.checkFile) return file;
34
- if (fs.existsSync(`${fileParts.join(path.sep)}.py`)) {
35
- return file;
31
+ const fileParts = fileName.split('.');
32
+ while (fileParts.length > 0) {
33
+ const file = `${fileParts.join(path_1.default.sep)}.py`;
34
+ if (!opts.checkFile)
35
+ return file;
36
+ if (fs_1.default.existsSync(`${fileParts.join(path_1.default.sep)}.py`)) {
37
+ return file;
38
+ }
39
+ fileParts.pop();
36
40
  }
37
- fileParts.pop();
38
- }
39
- return null;
41
+ return null;
40
42
  }
41
-
42
43
  module.exports = PythonAdapter;
@@ -1,10 +1,13 @@
1
- const Adapter = require('./adapter');
2
-
3
- class RubyAdapter extends Adapter {
4
- formatStack(t) {
5
- const stack = super.formatStack(t);
6
- return stack.replace(/\[(.*?:.\d*)\]/g, '\n$1');
7
- }
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 adapter_js_1 = __importDefault(require("./adapter.js"));
7
+ class RubyAdapter extends adapter_js_1.default {
8
+ formatStack(t) {
9
+ const stack = super.formatStack(t);
10
+ return stack.replace(/\[(.*?:.\d*)\]/g, '\n$1');
11
+ }
8
12
  }
9
-
10
13
  module.exports = RubyAdapter;