testcafe-reporter-qase 1.2.1 → 2.0.0-beta.1

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.
package/dist/index.js CHANGED
@@ -1,533 +1,3 @@
1
1
  "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __spreadArrays = (this && this.__spreadArrays) || function () {
54
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
55
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
56
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
57
- r[k] = a[j];
58
- return r;
59
- };
60
- var __importDefault = (this && this.__importDefault) || function (mod) {
61
- return (mod && mod.__esModule) ? mod : { "default": mod };
62
- };
63
- /* eslint-disable no-console,@typescript-eslint/require-await */
64
- /* eslint-disable camelcase */
65
- /* eslint-disable no-unused-vars */
66
- var CustomBoundaryFormData_1 = require("./CustomBoundaryFormData");
67
- var src_1 = require("qaseio/dist/src");
68
- var fs_1 = require("fs");
69
- var qaseio_1 = require("qaseio");
70
- var chalk_1 = __importDefault(require("chalk"));
71
- var child_process_1 = require("child_process");
72
- var moment_1 = __importDefault(require("moment"));
73
- var path_1 = __importDefault(require("path"));
74
- var RuntimeError = WebAssembly.RuntimeError;
75
- var loadJSON = function (file) {
76
- try {
77
- var data = fs_1.readFileSync(file, { encoding: 'utf8' });
78
- if (data) {
79
- return JSON.parse(data);
80
- }
81
- }
82
- catch (error) {
83
- // Ignore error when file does not exist or it's malformed
84
- }
85
- return undefined;
86
- };
87
- var prepareConfig = function (options) {
88
- if (options === void 0) { options = {}; }
89
- var loaded = loadJSON(path_1.default.join(process.cwd(), '.qaserc'));
90
- if (!loaded) {
91
- throw new RuntimeError();
92
- }
93
- var config = Object.assign(loaded, options);
94
- return {
95
- enabled: process.env.QASE_ENABLED === 'true' || config.enabled || false,
96
- apiToken: process.env.QASE_API_TOKEN || config.apiToken,
97
- basePath: process.env.QASE_API_BASE_URL || config.basePath,
98
- rootSuiteTitle: process.env.QASE_ROOT_SUITE_TITLE || config.rootSuiteTitle || '',
99
- projectCode: process.env.QASE_PROJECT || config.projectCode || '',
100
- runId: process.env.QASE_RUN_ID || config.runId || '',
101
- runName: process.env.QASE_RUN_NAME ||
102
- config.runName ||
103
- 'Automated Run %DATE%',
104
- runDescription: process.env.QASE_RUN_DESCRIPTION || config.runDescription,
105
- runComplete: process.env.QASE_RUN_COMPLETE === 'true' || config.runComplete,
106
- uploadAttachments: process.env.QASE_UPLOAD_ATTACHMENTS === 'true' || config.uploadAttachments,
107
- environmentId: process.env.QASE_ENVIRONMENT_ID || config.environmentId || undefined,
108
- logging: process.env.QASE_LOGGING !== '' || config.logging,
109
- };
110
- };
111
- var prepareReportName = function (config, userAgents) {
112
- var date = moment_1.default().format();
113
- return config.runName
114
- .replace('%DATE%', date)
115
- .replace('%AGENTS%', "(" + userAgents.join(', ') + ")");
116
- };
117
- var verifyConfig = function (config) {
118
- var enabled = config.enabled, apiToken = config.apiToken, projectCode = config.projectCode;
119
- if (enabled) {
120
- if (!projectCode) {
121
- console.log('[Qase] Project Code should be provided');
122
- }
123
- if (apiToken && projectCode) {
124
- return true;
125
- }
126
- }
127
- return false;
128
- };
129
- var TestcafeQaseReporter = /** @class */ (function () {
130
- function TestcafeQaseReporter() {
131
- var _this = this;
132
- this.pending = [];
133
- this.results = [];
134
- this.reportTaskStart = function (_startTime, userAgents) { return __awaiter(_this, void 0, void 0, function () {
135
- var _this = this;
136
- return __generator(this, function (_a) {
137
- if (!this.enabled) {
138
- return [2 /*return*/];
139
- }
140
- this.userAgents = userAgents;
141
- this.config.runName = prepareReportName(this.config, this.userAgents);
142
- return [2 /*return*/, this.checkProject(this.config.projectCode, function (prjExists) { return __awaiter(_this, void 0, void 0, function () {
143
- var _this = this;
144
- return __generator(this, function (_a) {
145
- if (!prjExists) {
146
- this.log(chalk_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["{red Project ", " does not exist}"], ["{red Project ", " does not exist}"])), this.config.projectCode));
147
- this.enabled = false;
148
- return [2 /*return*/];
149
- }
150
- this.log(chalk_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["{green Project ", " exists}"], ["{green Project ", " exists}"])), this.config.projectCode));
151
- if (this.config.runId) {
152
- this.saveRunId(this.config.runId);
153
- return [2 /*return*/, this.checkRun(this.config.runId, function (runExists) {
154
- if (runExists) {
155
- _this.log(chalk_1.default(templateObject_3 || (templateObject_3 = __makeTemplateObject(["{green Using run ", " to publish test results}"], ["{green Using run ", " to publish test results}"])), _this.config.runId));
156
- }
157
- else {
158
- _this.log(chalk_1.default(templateObject_4 || (templateObject_4 = __makeTemplateObject(["{red Run ", " does not exist}"], ["{red Run ", " does not exist}"])), _this.config.runId));
159
- _this.enabled = false;
160
- }
161
- })];
162
- }
163
- else {
164
- return [2 /*return*/, this.createRun(this.config.runName, this.config.runDescription, function (created) {
165
- var _a;
166
- if (created) {
167
- _this.saveRunId((_a = created.result) === null || _a === void 0 ? void 0 : _a.id);
168
- _this.log(chalk_1.default(templateObject_5 || (templateObject_5 = __makeTemplateObject(["{green Using run ", " to publish test results}"], ["{green Using run ", " to publish test results}"])), _this.config.runId));
169
- }
170
- else {
171
- _this.log(chalk_1.default(templateObject_6 || (templateObject_6 = __makeTemplateObject(["{red Could not create run in project ", "}"], ["{red Could not create run in project ", "}"])), _this.config.projectCode));
172
- _this.enabled = false;
173
- }
174
- })];
175
- }
176
- return [2 /*return*/];
177
- });
178
- }); })];
179
- });
180
- }); };
181
- this.reportFixtureStart = function (name) { return __awaiter(_this, void 0, void 0, function () {
182
- return __generator(this, function (_a) {
183
- this.fixtureName = String(name);
184
- return [2 /*return*/];
185
- });
186
- }); };
187
- this.reportTestDone = function (name, testRunInfo, meta, formatError) { return __awaiter(_this, void 0, void 0, function () {
188
- var hasErr, testStatus, errorLog, attachmentsArray;
189
- return __generator(this, function (_a) {
190
- switch (_a.label) {
191
- case 0:
192
- if (!this.enabled) {
193
- return [2 /*return*/];
194
- }
195
- this.queued++;
196
- hasErr = testRunInfo.errs.length;
197
- if (testRunInfo.skipped) {
198
- testStatus = src_1.ResultCreateStatusEnum.SKIPPED;
199
- }
200
- else if (hasErr > 0) {
201
- testStatus = src_1.ResultCreateStatusEnum.FAILED;
202
- }
203
- else {
204
- testStatus = src_1.ResultCreateStatusEnum.PASSED;
205
- }
206
- errorLog = testRunInfo.errs
207
- .map(function (x) { return formatError(x).replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''); })
208
- .join('\n');
209
- attachmentsArray = [];
210
- if (!(this.config.uploadAttachments && testRunInfo.screenshots.length > 0)) return [3 /*break*/, 2];
211
- return [4 /*yield*/, this.uploadAttachments(testRunInfo)];
212
- case 1:
213
- attachmentsArray = _a.sent();
214
- _a.label = 2;
215
- case 2:
216
- this.prepareCaseResult({ name: name, info: testRunInfo, meta: meta, error: errorLog }, testStatus, attachmentsArray);
217
- return [2 /*return*/];
218
- }
219
- });
220
- }); };
221
- this.reportTaskDone = function () { return __awaiter(_this, void 0, void 0, function () {
222
- var body;
223
- var _this = this;
224
- return __generator(this, function (_a) {
225
- switch (_a.label) {
226
- case 0:
227
- if (!this.enabled) {
228
- return [2 /*return*/];
229
- }
230
- return [4 /*yield*/, new Promise(function (resolve, reject) {
231
- var timer = 0;
232
- var interval = setInterval(function () {
233
- timer++;
234
- if (_this.config.runId && _this.queued === 0) {
235
- clearInterval(interval);
236
- resolve();
237
- }
238
- if (timer > 30) {
239
- clearInterval(interval);
240
- reject();
241
- }
242
- }, 1000);
243
- })];
244
- case 1:
245
- _a.sent();
246
- if (!(this.results.length === 0)) return [3 /*break*/, 2];
247
- console.warn("\n(Qase Reporter)\n \nNo testcases were matched.\n Ensure that your tests are declared correctly.\n");
248
- return [3 /*break*/, 5];
249
- case 2:
250
- body = {
251
- results: this.results,
252
- };
253
- return [4 /*yield*/, this.api.results.createResultBulk(this.config.projectCode, Number(this.config.runId), body)];
254
- case 3:
255
- _a.sent();
256
- this.log('Results sent to Qase');
257
- if (!this.config.runComplete) return [3 /*break*/, 5];
258
- return [4 /*yield*/, this.completeRun(this.config.runId)];
259
- case 4:
260
- _a.sent();
261
- _a.label = 5;
262
- case 5: return [2 /*return*/];
263
- }
264
- });
265
- }); };
266
- this.config = prepareConfig();
267
- this.enabled = verifyConfig(this.config);
268
- this.api = new qaseio_1.QaseApi(this.config.apiToken, this.config.basePath, TestcafeQaseReporter.createHeaders(), CustomBoundaryFormData_1.CustomBoundaryFormData);
269
- this.queued = 0;
270
- this.fixtureName = '';
271
- this.screenshots = {};
272
- }
273
- TestcafeQaseReporter.getCaseId = function (meta) {
274
- if (!meta.CID) {
275
- return [];
276
- }
277
- return meta.CID;
278
- };
279
- TestcafeQaseReporter.createHeaders = function () {
280
- var nodeVersion = process.version, os = process.platform, arch = process.arch;
281
- var npmVersion = child_process_1.execSync('npm -v', { encoding: 'utf8' }).replace(/['"\n]+/g, '');
282
- var qaseapiVersion = this.getPackageVersion('qaseio');
283
- var testcafeVersion = this.getPackageVersion('testcafe');
284
- var testcafeCaseReporterVersion = this.getPackageVersion('testcafe-reporter-qase');
285
- var xPlatformHeader = "node=" + nodeVersion + "; npm=" + npmVersion + "; os=" + os + "; arch=" + arch;
286
- // eslint-disable-next-line max-len
287
- var xClientHeader = "testcafe=" + testcafeVersion + "; qase-testcafe=" + testcafeCaseReporterVersion + "; qaseapi=" + qaseapiVersion;
288
- return {
289
- 'X-Client': xClientHeader,
290
- 'X-Platform': xPlatformHeader,
291
- };
292
- };
293
- TestcafeQaseReporter.createRunObject = function (name, cases, args) {
294
- return __assign({ title: name, cases: cases }, args);
295
- };
296
- TestcafeQaseReporter.getPackageVersion = function (name) {
297
- var UNDEFINED = 'undefined';
298
- try {
299
- var pathToPackageJson = require.resolve(name + "/package.json", { paths: [process.cwd()] });
300
- if (pathToPackageJson) {
301
- try {
302
- var packageString = fs_1.readFileSync(pathToPackageJson, { encoding: 'utf8' });
303
- if (packageString) {
304
- var packageObject = JSON.parse(packageString);
305
- return packageObject.version;
306
- }
307
- return UNDEFINED;
308
- }
309
- catch (error) {
310
- return UNDEFINED;
311
- }
312
- }
313
- }
314
- catch (error) {
315
- return UNDEFINED;
316
- }
317
- };
318
- TestcafeQaseReporter.prototype.completeRun = function (runId) {
319
- return __awaiter(this, void 0, void 0, function () {
320
- var _this = this;
321
- return __generator(this, function (_a) {
322
- switch (_a.label) {
323
- case 0:
324
- if (!(runId !== undefined)) return [3 /*break*/, 2];
325
- return [4 /*yield*/, this.api.runs.completeRun(this.config.projectCode, Number(this.config.runId))
326
- .then(function () {
327
- _this.log('Run completed successfully');
328
- })
329
- .catch(function (err) {
330
- _this.log("Error on completing run " + err);
331
- })];
332
- case 1:
333
- _a.sent();
334
- _a.label = 2;
335
- case 2: return [2 /*return*/];
336
- }
337
- });
338
- });
339
- };
340
- TestcafeQaseReporter.prototype.log = function (message) {
341
- var optionalParams = [];
342
- for (var _i = 1; _i < arguments.length; _i++) {
343
- optionalParams[_i - 1] = arguments[_i];
344
- }
345
- if (this.config.logging) {
346
- console.log.apply(console, __spreadArrays([chalk_1.default(templateObject_7 || (templateObject_7 = __makeTemplateObject(["{bold {blue qase:}} ", ""], ["{bold {blue qase:}} ", ""])), message)], optionalParams));
347
- }
348
- };
349
- TestcafeQaseReporter.prototype.checkProject = function (projectCode, cb) {
350
- var _a;
351
- return __awaiter(this, void 0, void 0, function () {
352
- var resp, err_1;
353
- return __generator(this, function (_b) {
354
- switch (_b.label) {
355
- case 0:
356
- _b.trys.push([0, 3, , 4]);
357
- return [4 /*yield*/, this.api.projects.getProject(projectCode)];
358
- case 1:
359
- resp = _b.sent();
360
- return [4 /*yield*/, cb(Boolean((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.code))];
361
- case 2:
362
- _b.sent();
363
- return [3 /*break*/, 4];
364
- case 3:
365
- err_1 = _b.sent();
366
- this.log("Error on checking project " + err_1);
367
- this.enabled = false;
368
- return [3 /*break*/, 4];
369
- case 4: return [2 /*return*/];
370
- }
371
- });
372
- });
373
- };
374
- TestcafeQaseReporter.prototype.createRun = function (name, description, cb) {
375
- return __awaiter(this, void 0, void 0, function () {
376
- var runObject, res, err_2;
377
- return __generator(this, function (_a) {
378
- switch (_a.label) {
379
- case 0:
380
- _a.trys.push([0, 2, , 3]);
381
- runObject = TestcafeQaseReporter.createRunObject(name || "Automated run " + new Date().toISOString(), [], {
382
- description: description || 'TestCafe automated run',
383
- environment_id: Number(this.config.environmentId),
384
- is_autotest: true,
385
- });
386
- return [4 /*yield*/, this.api.runs.createRun(this.config.projectCode, runObject)];
387
- case 1:
388
- res = _a.sent();
389
- cb(res.data);
390
- return [3 /*break*/, 3];
391
- case 2:
392
- err_2 = _a.sent();
393
- this.log("Error on creating run " + err_2);
394
- this.enabled = false;
395
- return [3 /*break*/, 3];
396
- case 3: return [2 /*return*/];
397
- }
398
- });
399
- });
400
- };
401
- TestcafeQaseReporter.prototype.checkRun = function (runId, cb) {
402
- return __awaiter(this, void 0, void 0, function () {
403
- var _this = this;
404
- return __generator(this, function (_a) {
405
- if (runId === undefined) {
406
- cb(false);
407
- return [2 /*return*/];
408
- }
409
- return [2 /*return*/, this.api.runs.getRun(this.config.projectCode, Number(runId))
410
- .then(function (resp) {
411
- var _a, _b;
412
- _this.log("Get run result on checking run " + ((_a = resp.data.result) === null || _a === void 0 ? void 0 : _a.id));
413
- cb(Boolean((_b = resp.data.result) === null || _b === void 0 ? void 0 : _b.id));
414
- })
415
- .catch(function (err) {
416
- _this.log("Error on checking run " + err);
417
- _this.enabled = false;
418
- })];
419
- });
420
- });
421
- };
422
- TestcafeQaseReporter.prototype.saveRunId = function (runId) {
423
- this.config.runId = runId;
424
- if (this.config.runId) {
425
- while (this.pending.length) {
426
- this.log("Number of pending: " + this.pending.length);
427
- var cb = this.pending.shift();
428
- if (cb) {
429
- cb(this.config.runId);
430
- }
431
- }
432
- }
433
- };
434
- TestcafeQaseReporter.prototype.logTestItem = function (name, status) {
435
- var map = {
436
- failed: chalk_1.default(templateObject_8 || (templateObject_8 = __makeTemplateObject(["{red Test ", " ", "}"], ["{red Test ", " ", "}"])), name, status),
437
- passed: chalk_1.default(templateObject_9 || (templateObject_9 = __makeTemplateObject(["{green Test ", " ", "}"], ["{green Test ", " ", "}"])), name, status),
438
- pending: chalk_1.default(templateObject_10 || (templateObject_10 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), name, status),
439
- skipped: chalk_1.default(templateObject_11 || (templateObject_11 = __makeTemplateObject(["{blueBright Test ", " ", "}"], ["{blueBright Test ", " ", "}"])), name, status),
440
- };
441
- if (status) {
442
- this.log(map[status]);
443
- }
444
- };
445
- TestcafeQaseReporter.prototype.prepareCaseResult = function (test, status, attachments) {
446
- var _this = this;
447
- this.logTestItem(test.name, status);
448
- this.queued--;
449
- var caseObject = {
450
- status: status,
451
- time_ms: test.info.durationMs,
452
- stacktrace: test.error,
453
- comment: test.error ? test.error.split('\n')[0] : undefined,
454
- attachments: attachments.length > 0
455
- ? attachments
456
- : undefined,
457
- defect: status === src_1.ResultCreateStatusEnum.FAILED,
458
- };
459
- if (!test.meta.CID) {
460
- caseObject.case = {
461
- title: test.name,
462
- suite_title: this.config.rootSuiteTitle
463
- ? this.config.rootSuiteTitle + '\t' + this.fixtureName
464
- : this.fixtureName,
465
- };
466
- this.results.push(caseObject);
467
- }
468
- else {
469
- var caseIds_1 = TestcafeQaseReporter.getCaseId(test.meta);
470
- caseIds_1.forEach(function (caseId) {
471
- if (caseId) {
472
- var add = caseIds_1.length > 1 ? chalk_1.default(templateObject_12 || (templateObject_12 = __makeTemplateObject([" {white For case ", "}"], [" {white For case ", "}"])), caseId) : '';
473
- _this.log(chalk_1.default(templateObject_13 || (templateObject_13 = __makeTemplateObject(["{gray Ready for publishing: ", "}", ""], ["{gray Ready for publishing: ", "}", ""])), test.name, add));
474
- var caseObjectWithId = __assign({ case_id: parseInt(caseId, 10) }, caseObject);
475
- _this.results.push(caseObjectWithId);
476
- }
477
- });
478
- }
479
- };
480
- TestcafeQaseReporter.prototype.uploadAttachments = function (testRunInfo) {
481
- return __awaiter(this, void 0, void 0, function () {
482
- var _this = this;
483
- return __generator(this, function (_a) {
484
- switch (_a.label) {
485
- case 0: return [4 /*yield*/, Promise.all(testRunInfo.screenshots.map(function (attachment) { return __awaiter(_this, void 0, void 0, function () {
486
- var data, options, response;
487
- var _a;
488
- return __generator(this, function (_b) {
489
- switch (_b.label) {
490
- case 0:
491
- data = fs_1.createReadStream(attachment === null || attachment === void 0 ? void 0 : attachment.screenshotPath);
492
- options = {
493
- headers: {
494
- 'Content-Type': 'multipart/form-data; boundary=' + CustomBoundaryFormData_1.customBoundary,
495
- },
496
- };
497
- return [4 /*yield*/, this.api.attachments.uploadAttachment(this.config.projectCode, [data], options)];
498
- case 1:
499
- response = _b.sent();
500
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
501
- return [2 /*return*/, (_a = response.data.result) === null || _a === void 0 ? void 0 : _a[0].hash];
502
- }
503
- });
504
- }); }))];
505
- case 1: return [2 /*return*/, _a.sent()];
506
- }
507
- });
508
- });
509
- };
510
- return TestcafeQaseReporter;
511
- }());
512
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13;
513
- module.exports = function () {
514
- var reporter = new TestcafeQaseReporter();
515
- return {
516
- reportTaskStart: reporter.reportTaskStart,
517
- reportFixtureStart: reporter.reportFixtureStart,
518
- reportTestDone: function (name, testRunInfo, meta) {
519
- return __awaiter(this, void 0, void 0, function () {
520
- return __generator(this, function (_a) {
521
- return [2 /*return*/, reporter.reportTestDone(name, testRunInfo, meta,
522
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
523
- // @ts-expect-error Inject testrail error formatting method with bound context
524
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
525
- this.formatError.bind(this))];
526
- });
527
- });
528
- },
529
- reportTaskDone: reporter.reportTaskDone,
530
- reporter: reporter,
531
- };
532
- };
533
- //# sourceMappingURL=index.js.map
2
+ const factory_1 = require("./factory");
3
+ module.exports = factory_1.factory;
@@ -0,0 +1,95 @@
1
+ import { ConfigLoader, ConfigType } from 'qase-javascript-commons';
2
+ type CallsiteRecordType = {
3
+ filename?: string;
4
+ lineNum?: number;
5
+ callsiteFrameIdx?: number;
6
+ stackFrames?: Array<unknown>;
7
+ isV8Frames?: boolean;
8
+ };
9
+ type TestRunErrorFormattableAdapterType = {
10
+ userAgent: string;
11
+ screenshotPath: string;
12
+ testRunId: string;
13
+ testRunPhase: string;
14
+ code?: string;
15
+ isTestCafeError?: boolean;
16
+ callsite?: CallsiteRecordType;
17
+ errMsg?: string;
18
+ diff?: boolean;
19
+ id?: string;
20
+ };
21
+ type ScreenshotType = {
22
+ screenshotPath: string;
23
+ thumbnailPath: string;
24
+ userAgent: string;
25
+ quarantineAttempt: number;
26
+ takenOnFail: boolean;
27
+ };
28
+ type FixtureType = {
29
+ id: string;
30
+ name: string;
31
+ path?: string;
32
+ meta: Record<string, unknown>;
33
+ };
34
+ export type TestRunInfoType = {
35
+ errs: TestRunErrorFormattableAdapterType[];
36
+ warnings: string[];
37
+ durationMs: number;
38
+ unstable: boolean;
39
+ screenshotPath: string;
40
+ screenshots: ScreenshotType[];
41
+ quarantine: Record<string, Record<'passed', boolean>>;
42
+ skipped: boolean;
43
+ fixture: FixtureType;
44
+ };
45
+ export type TestcafeQaseOptionsType = ConfigType;
46
+ /**
47
+ * @class TestcafeQaseReporter
48
+ */
49
+ export declare class TestcafeQaseReporter {
50
+ /**
51
+ * @param {Record<string, string>} meta
52
+ * @returns {number[]}
53
+ * @private
54
+ */
55
+ private static getCaseId;
56
+ /**
57
+ * @param {TestRunInfoType} testRunInfo
58
+ * @returns {TestStatusEnum}
59
+ * @private
60
+ */
61
+ private static getStatus;
62
+ /**
63
+ * @param {TestRunErrorFormattableAdapterType[]} errors
64
+ * @returns {Error}
65
+ * @private
66
+ */
67
+ private static transformErrors;
68
+ /**
69
+ * @param {ScreenshotType[]} attachments
70
+ * @returns {string[]}
71
+ * @private
72
+ */
73
+ private static transformAttachments;
74
+ /**
75
+ * @type {ReporterInterface}
76
+ * @private
77
+ */
78
+ private reporter;
79
+ /**
80
+ * @param {TestcafeQaseOptionsType} options
81
+ * @param {ConfigLoaderInterface} configLoader
82
+ */
83
+ constructor(options: TestcafeQaseOptionsType, configLoader?: ConfigLoader<Partial<ConfigType> & Record<string, unknown>>);
84
+ /**
85
+ * @param {string} title
86
+ * @param {TestRunInfoType} testRunInfo
87
+ * @param {Record<string, string>} meta
88
+ */
89
+ reportTestDone: (title: string, testRunInfo: TestRunInfoType, meta: Record<string, string>) => void;
90
+ /**
91
+ * @returns {Promise<void>}
92
+ */
93
+ reportTaskDone: () => Promise<void>;
94
+ }
95
+ export {};