qagentic-reporter 0.1.3 → 0.1.5

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.
@@ -0,0 +1,684 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var uuid = require('uuid');
6
+ var fs2 = require('fs');
7
+ var path2 = require('path');
8
+ var axios = require('axios');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
31
+ var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
32
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
33
+
34
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
35
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
36
+ }) : x)(function(x) {
37
+ if (typeof require !== "undefined") return require.apply(this, arguments);
38
+ throw Error('Dynamic require of "' + x + '" is not supported');
39
+ });
40
+ var defaultConfig = {
41
+ projectName: "default",
42
+ environment: "local",
43
+ api: {
44
+ enabled: true,
45
+ url: "http://localhost:8080",
46
+ timeout: 3e4,
47
+ retryCount: 3,
48
+ batchSize: 100
49
+ },
50
+ local: {
51
+ enabled: true,
52
+ outputDir: "./qagentic-results",
53
+ formats: ["json", "html"],
54
+ cleanOnStart: true
55
+ },
56
+ features: {
57
+ aiAnalysis: true,
58
+ failureClustering: true,
59
+ flakyDetection: true,
60
+ screenshots: "on_failure",
61
+ videos: "on_failure",
62
+ consoleOutput: true
63
+ },
64
+ labels: {
65
+ custom: {}
66
+ }
67
+ };
68
+ var globalConfig = { ...defaultConfig };
69
+ function loadFromEnv(config) {
70
+ const env = process.env;
71
+ if (env.QAGENTIC_PROJECT_NAME) {
72
+ config.projectName = env.QAGENTIC_PROJECT_NAME;
73
+ }
74
+ if (env.QAGENTIC_ENVIRONMENT) {
75
+ config.environment = env.QAGENTIC_ENVIRONMENT;
76
+ }
77
+ if (env.QAGENTIC_API_ENABLED !== void 0) {
78
+ config.api.enabled = env.QAGENTIC_API_ENABLED.toLowerCase() === "true";
79
+ }
80
+ if (env.QAGENTIC_API_URL) {
81
+ config.api.url = env.QAGENTIC_API_URL;
82
+ }
83
+ if (env.QAGENTIC_API_KEY) {
84
+ config.api.key = env.QAGENTIC_API_KEY;
85
+ }
86
+ if (env.QAGENTIC_LOCAL_ENABLED !== void 0) {
87
+ config.local.enabled = env.QAGENTIC_LOCAL_ENABLED.toLowerCase() === "true";
88
+ }
89
+ if (env.QAGENTIC_OUTPUT_DIR) {
90
+ config.local.outputDir = env.QAGENTIC_OUTPUT_DIR;
91
+ }
92
+ if (env.QAGENTIC_OUTPUT_FORMAT) {
93
+ config.local.formats = env.QAGENTIC_OUTPUT_FORMAT.split(",").map(
94
+ (f) => f.trim()
95
+ );
96
+ }
97
+ if (env.QAGENTIC_AI_ANALYSIS !== void 0) {
98
+ config.features.aiAnalysis = env.QAGENTIC_AI_ANALYSIS.toLowerCase() === "true";
99
+ }
100
+ if (env.QAGENTIC_SCREENSHOTS) {
101
+ config.features.screenshots = env.QAGENTIC_SCREENSHOTS;
102
+ }
103
+ if (env.QAGENTIC_VIDEOS) {
104
+ config.features.videos = env.QAGENTIC_VIDEOS;
105
+ }
106
+ if (env.QAGENTIC_TEAM) {
107
+ config.labels.team = env.QAGENTIC_TEAM;
108
+ }
109
+ if (env.QAGENTIC_COMPONENT) {
110
+ config.labels.component = env.QAGENTIC_COMPONENT;
111
+ }
112
+ return config;
113
+ }
114
+ function loadFromFile(filePath, config) {
115
+ try {
116
+ if (!fs2__namespace.existsSync(filePath)) {
117
+ return config;
118
+ }
119
+ const content = fs2__namespace.readFileSync(filePath, "utf-8");
120
+ const yaml = __require("yaml");
121
+ const data = yaml.parse(content);
122
+ if (data.project) {
123
+ if (data.project.name) config.projectName = data.project.name;
124
+ if (data.project.environment) config.environment = data.project.environment;
125
+ }
126
+ if (data.reporting?.api) {
127
+ if (data.reporting.api.enabled !== void 0) config.api.enabled = data.reporting.api.enabled;
128
+ if (data.reporting.api.url) config.api.url = data.reporting.api.url;
129
+ if (data.reporting.api.key) config.api.key = data.reporting.api.key;
130
+ }
131
+ if (data.reporting?.local) {
132
+ if (data.reporting.local.enabled !== void 0)
133
+ config.local.enabled = data.reporting.local.enabled;
134
+ if (data.reporting.local.output_dir) config.local.outputDir = data.reporting.local.output_dir;
135
+ if (data.reporting.local.formats) config.local.formats = data.reporting.local.formats;
136
+ }
137
+ if (data.features) {
138
+ if (data.features.ai_analysis !== void 0)
139
+ config.features.aiAnalysis = data.features.ai_analysis;
140
+ if (data.features.failure_clustering !== void 0)
141
+ config.features.failureClustering = data.features.failure_clustering;
142
+ if (data.features.flaky_detection !== void 0)
143
+ config.features.flakyDetection = data.features.flaky_detection;
144
+ if (data.features.screenshots) config.features.screenshots = data.features.screenshots;
145
+ if (data.features.videos) config.features.videos = data.features.videos;
146
+ }
147
+ if (data.labels) {
148
+ if (data.labels.team) config.labels.team = data.labels.team;
149
+ if (data.labels.component) config.labels.component = data.labels.component;
150
+ config.labels.custom = { ...config.labels.custom, ...data.labels };
151
+ }
152
+ } catch (error) {
153
+ console.warn(`Failed to load config from ${filePath}:`, error);
154
+ }
155
+ return config;
156
+ }
157
+ function autoDiscover() {
158
+ const config = { ...defaultConfig };
159
+ const cwd = process.cwd();
160
+ const searchPaths = [
161
+ path2__namespace.join(cwd, "qagentic.yaml"),
162
+ path2__namespace.join(cwd, "qagentic.yml"),
163
+ path2__namespace.join(cwd, ".qagentic.yaml"),
164
+ path2__namespace.join(cwd, ".qagentic.yml")
165
+ ];
166
+ for (const filePath of searchPaths) {
167
+ if (fs2__namespace.existsSync(filePath)) {
168
+ loadFromFile(filePath, config);
169
+ break;
170
+ }
171
+ }
172
+ return loadFromEnv(config);
173
+ }
174
+ function configure(options = {}) {
175
+ globalConfig = autoDiscover();
176
+ if (options.projectName) {
177
+ globalConfig.projectName = options.projectName;
178
+ }
179
+ if (options.environment) {
180
+ globalConfig.environment = options.environment;
181
+ }
182
+ if (options.apiUrl) {
183
+ globalConfig.api.url = options.apiUrl;
184
+ }
185
+ if (options.apiKey) {
186
+ globalConfig.api.key = options.apiKey;
187
+ }
188
+ if (options.outputDir) {
189
+ globalConfig.local.outputDir = options.outputDir;
190
+ }
191
+ if (options.api) {
192
+ globalConfig.api = { ...globalConfig.api, ...options.api };
193
+ }
194
+ if (options.local) {
195
+ globalConfig.local = { ...globalConfig.local, ...options.local };
196
+ }
197
+ if (options.features) {
198
+ globalConfig.features = { ...globalConfig.features, ...options.features };
199
+ }
200
+ if (options.labels) {
201
+ globalConfig.labels = { ...globalConfig.labels, ...options.labels };
202
+ }
203
+ return globalConfig;
204
+ }
205
+ function getConfig() {
206
+ return globalConfig;
207
+ }
208
+
209
+ // src/core/status.ts
210
+ function parseStatus(value) {
211
+ const normalized = value.toLowerCase();
212
+ switch (normalized) {
213
+ case "passed":
214
+ case "pass":
215
+ case "success":
216
+ return "passed" /* PASSED */;
217
+ case "failed":
218
+ case "fail":
219
+ case "failure":
220
+ return "failed" /* FAILED */;
221
+ case "broken":
222
+ case "error":
223
+ return "broken" /* BROKEN */;
224
+ case "skipped":
225
+ case "skip":
226
+ case "pending":
227
+ return "skipped" /* SKIPPED */;
228
+ case "running":
229
+ return "running" /* RUNNING */;
230
+ default:
231
+ return "unknown" /* UNKNOWN */;
232
+ }
233
+ }
234
+
235
+ // src/core/reporter.ts
236
+ var ConsoleReporter = class {
237
+ constructor(config) {
238
+ this.config = config || getConfig();
239
+ }
240
+ startRun(run) {
241
+ console.log("\n" + "=".repeat(60));
242
+ console.log(`\u{1F680} QAagentic Test Run - ${run.projectName}`);
243
+ console.log(`Environment: ${run.environment}`);
244
+ console.log("=".repeat(60) + "\n");
245
+ }
246
+ endRun(run) {
247
+ const icon = run.failed === 0 ? "\u2705" : "\u274C";
248
+ console.log("\n" + "=".repeat(60));
249
+ console.log(`${icon} Test Run Complete - ${run.passRate.toFixed(1)}% Pass Rate`);
250
+ console.log(`Passed: ${run.passed} | Failed: ${run.failed} | Skipped: ${run.skipped}`);
251
+ console.log("=".repeat(60) + "\n");
252
+ }
253
+ reportTest(test) {
254
+ if (!this.config.features.consoleOutput) return;
255
+ const symbols = {
256
+ ["passed" /* PASSED */]: "\u2713",
257
+ ["failed" /* FAILED */]: "\u2717",
258
+ ["broken" /* BROKEN */]: "!",
259
+ ["skipped" /* SKIPPED */]: "\u25CB",
260
+ ["pending" /* PENDING */]: "\u2026",
261
+ ["running" /* RUNNING */]: "\u2192",
262
+ ["unknown" /* UNKNOWN */]: "?"
263
+ };
264
+ const symbol = symbols[test.status] || "?";
265
+ console.log(` ${symbol} ${test.name}`);
266
+ if (test.errorMessage) {
267
+ console.log(` Error: ${test.errorMessage.slice(0, 100)}...`);
268
+ }
269
+ }
270
+ };
271
+ var JSONReporter = class {
272
+ constructor(config) {
273
+ this.config = config || getConfig();
274
+ this.outputDir = this.config.local.outputDir;
275
+ }
276
+ startRun(run) {
277
+ if (!fs2__namespace.existsSync(this.outputDir)) {
278
+ fs2__namespace.mkdirSync(this.outputDir, { recursive: true });
279
+ }
280
+ if (this.config.local.cleanOnStart) {
281
+ const files = fs2__namespace.readdirSync(this.outputDir);
282
+ for (const file of files) {
283
+ if (file.endsWith(".json")) {
284
+ fs2__namespace.unlinkSync(path2__namespace.join(this.outputDir, file));
285
+ }
286
+ }
287
+ }
288
+ }
289
+ endRun(run) {
290
+ if (!this.config.local.enabled || !this.config.local.formats.includes("json")) {
291
+ return;
292
+ }
293
+ const runFile = path2__namespace.join(this.outputDir, "run.json");
294
+ fs2__namespace.writeFileSync(runFile, JSON.stringify(this.serializeRun(run), null, 2));
295
+ const testsDir = path2__namespace.join(this.outputDir, "tests");
296
+ if (!fs2__namespace.existsSync(testsDir)) {
297
+ fs2__namespace.mkdirSync(testsDir, { recursive: true });
298
+ }
299
+ for (const test of run.tests) {
300
+ const testFile = path2__namespace.join(testsDir, `${test.id}.json`);
301
+ fs2__namespace.writeFileSync(testFile, JSON.stringify(this.serializeTest(test), null, 2));
302
+ }
303
+ }
304
+ reportTest(_test) {
305
+ }
306
+ serializeRun(run) {
307
+ return {
308
+ ...run,
309
+ startTime: run.startTime?.toISOString(),
310
+ endTime: run.endTime?.toISOString(),
311
+ tests: run.tests.map((t) => this.serializeTest(t))
312
+ };
313
+ }
314
+ serializeTest(test) {
315
+ return {
316
+ ...test,
317
+ startTime: test.startTime?.toISOString(),
318
+ endTime: test.endTime?.toISOString(),
319
+ steps: test.steps.map((s) => this.serializeStep(s))
320
+ };
321
+ }
322
+ serializeStep(step) {
323
+ return {
324
+ ...step,
325
+ startTime: step.startTime?.toISOString(),
326
+ endTime: step.endTime?.toISOString(),
327
+ children: step.children.map((c) => this.serializeStep(c))
328
+ };
329
+ }
330
+ };
331
+ var JUnitReporter = class {
332
+ constructor(config) {
333
+ this.config = config || getConfig();
334
+ this.outputDir = this.config.local.outputDir;
335
+ }
336
+ startRun(_run) {
337
+ if (!fs2__namespace.existsSync(this.outputDir)) {
338
+ fs2__namespace.mkdirSync(this.outputDir, { recursive: true });
339
+ }
340
+ }
341
+ endRun(run) {
342
+ if (!this.config.local.enabled || !this.config.local.formats.includes("junit")) {
343
+ return;
344
+ }
345
+ const xml = this.generateXml(run);
346
+ const junitFile = path2__namespace.join(this.outputDir, "junit.xml");
347
+ fs2__namespace.writeFileSync(junitFile, xml);
348
+ }
349
+ reportTest(_test) {
350
+ }
351
+ generateXml(run) {
352
+ const escape = (str) => str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
353
+ let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
354
+ xml += `<testsuite name="${escape(run.projectName)}" `;
355
+ xml += `tests="${run.total}" `;
356
+ xml += `failures="${run.failed}" `;
357
+ xml += `errors="${run.broken}" `;
358
+ xml += `skipped="${run.skipped}" `;
359
+ xml += `time="${(run.durationMs / 1e3).toFixed(3)}" `;
360
+ xml += `timestamp="${run.startTime?.toISOString() || ""}">
361
+ `;
362
+ for (const test of run.tests) {
363
+ xml += ` <testcase name="${escape(test.name)}" `;
364
+ xml += `classname="${escape(test.fullName)}" `;
365
+ xml += `time="${(test.durationMs / 1e3).toFixed(3)}"`;
366
+ if (test.status === "passed" /* PASSED */) {
367
+ xml += "/>\n";
368
+ } else if (test.status === "failed" /* FAILED */) {
369
+ xml += ">\n";
370
+ xml += ` <failure message="${escape(test.errorMessage || "Test failed")}" `;
371
+ xml += `type="${escape(test.errorType || "AssertionError")}">`;
372
+ if (test.stackTrace) {
373
+ xml += escape(test.stackTrace);
374
+ }
375
+ xml += "</failure>\n";
376
+ xml += " </testcase>\n";
377
+ } else if (test.status === "broken" /* BROKEN */) {
378
+ xml += ">\n";
379
+ xml += ` <error message="${escape(test.errorMessage || "Test error")}" `;
380
+ xml += `type="${escape(test.errorType || "Error")}">`;
381
+ if (test.stackTrace) {
382
+ xml += escape(test.stackTrace);
383
+ }
384
+ xml += "</error>\n";
385
+ xml += " </testcase>\n";
386
+ } else if (test.status === "skipped" /* SKIPPED */) {
387
+ xml += ">\n";
388
+ xml += ` <skipped${test.errorMessage ? ` message="${escape(test.errorMessage)}"` : ""}/>
389
+ `;
390
+ xml += " </testcase>\n";
391
+ } else {
392
+ xml += "/>\n";
393
+ }
394
+ }
395
+ xml += "</testsuite>\n";
396
+ return xml;
397
+ }
398
+ };
399
+ var APIReporter = class {
400
+ constructor(config) {
401
+ this.batch = [];
402
+ this.config = config || getConfig();
403
+ }
404
+ async startRun(run) {
405
+ if (!this.config.api.enabled) return;
406
+ this.currentRun = run;
407
+ this.batch = [];
408
+ try {
409
+ await axios__default.default.post(
410
+ `${this.config.api.url}/api/v1/runs`,
411
+ {
412
+ id: run.id,
413
+ name: run.name,
414
+ project_name: run.projectName,
415
+ environment: run.environment,
416
+ start_time: run.startTime?.toISOString(),
417
+ labels: run.labels,
418
+ ci_build_id: run.ciBuildId,
419
+ branch: run.branch,
420
+ commit_hash: run.commitHash
421
+ },
422
+ {
423
+ headers: {
424
+ "Content-Type": "application/json",
425
+ "X-API-Key": this.config.api.key || "",
426
+ "X-Project": this.config.projectName
427
+ },
428
+ timeout: this.config.api.timeout
429
+ }
430
+ );
431
+ } catch (error) {
432
+ console.warn("Warning: Failed to register run with API:", error);
433
+ }
434
+ }
435
+ async endRun(run) {
436
+ if (!this.config.api.enabled) return;
437
+ await this.flushBatch();
438
+ try {
439
+ await axios__default.default.patch(
440
+ `${this.config.api.url}/api/v1/runs/${run.id}`,
441
+ {
442
+ end_time: run.endTime?.toISOString(),
443
+ duration_ms: run.durationMs,
444
+ total: run.total,
445
+ passed: run.passed,
446
+ failed: run.failed,
447
+ broken: run.broken,
448
+ skipped: run.skipped,
449
+ status: "completed"
450
+ },
451
+ {
452
+ headers: {
453
+ "Content-Type": "application/json",
454
+ "X-API-Key": this.config.api.key || ""
455
+ },
456
+ timeout: this.config.api.timeout
457
+ }
458
+ );
459
+ } catch (error) {
460
+ console.warn("Warning: Failed to finalize run with API:", error);
461
+ }
462
+ }
463
+ async reportTest(test) {
464
+ if (!this.config.api.enabled) return;
465
+ this.batch.push(test);
466
+ if (this.batch.length >= this.config.api.batchSize) {
467
+ await this.flushBatch();
468
+ }
469
+ }
470
+ async flushBatch() {
471
+ if (this.batch.length === 0 || !this.currentRun) return;
472
+ try {
473
+ await axios__default.default.post(
474
+ `${this.config.api.url}/api/v1/runs/${this.currentRun.id}/results`,
475
+ this.batch.map((t) => ({
476
+ ...t,
477
+ startTime: t.startTime?.toISOString(),
478
+ endTime: t.endTime?.toISOString()
479
+ })),
480
+ {
481
+ headers: {
482
+ "Content-Type": "application/json",
483
+ "X-API-Key": this.config.api.key || ""
484
+ },
485
+ timeout: this.config.api.timeout
486
+ }
487
+ );
488
+ } catch (error) {
489
+ console.warn("Warning: Failed to send test results to API:", error);
490
+ } finally {
491
+ this.batch = [];
492
+ }
493
+ }
494
+ };
495
+ var _QAgenticReporter = class _QAgenticReporter {
496
+ constructor(config) {
497
+ this.reporters = [];
498
+ this.currentRun = null;
499
+ this.config = config || getConfig();
500
+ if (this.config.features.consoleOutput) {
501
+ this.reporters.push(new ConsoleReporter(this.config));
502
+ }
503
+ if (this.config.local.enabled) {
504
+ this.reporters.push(new JSONReporter(this.config));
505
+ if (this.config.local.formats.includes("junit")) {
506
+ this.reporters.push(new JUnitReporter(this.config));
507
+ }
508
+ }
509
+ if (this.config.api.enabled) {
510
+ this.reporters.push(new APIReporter(this.config));
511
+ }
512
+ }
513
+ /**
514
+ * Get singleton instance.
515
+ */
516
+ static getInstance(config) {
517
+ if (!_QAgenticReporter.instance) {
518
+ _QAgenticReporter.instance = new _QAgenticReporter(config);
519
+ }
520
+ return _QAgenticReporter.instance;
521
+ }
522
+ /**
523
+ * Reset singleton instance.
524
+ */
525
+ static reset() {
526
+ _QAgenticReporter.instance = null;
527
+ }
528
+ /**
529
+ * Start a new test run.
530
+ */
531
+ async startRun(options = {}) {
532
+ this.currentRun = {
533
+ id: options.id || uuid.v4(),
534
+ name: options.name || `run_${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "")}`,
535
+ projectName: options.projectName || this.config.projectName,
536
+ environment: options.environment || this.config.environment,
537
+ startTime: /* @__PURE__ */ new Date(),
538
+ durationMs: 0,
539
+ tests: [],
540
+ total: 0,
541
+ passed: 0,
542
+ failed: 0,
543
+ broken: 0,
544
+ skipped: 0,
545
+ passRate: 0,
546
+ labels: { ...this.config.labels.custom, ...options.labels },
547
+ parameters: options.parameters || {},
548
+ ciBuildId: options.ciBuildId,
549
+ ciBuildUrl: options.ciBuildUrl,
550
+ branch: options.branch,
551
+ commitHash: options.commitHash
552
+ };
553
+ for (const reporter of this.reporters) {
554
+ await reporter.startRun(this.currentRun);
555
+ }
556
+ return this.currentRun;
557
+ }
558
+ /**
559
+ * End the current test run.
560
+ */
561
+ async endRun() {
562
+ if (!this.currentRun) return null;
563
+ this.currentRun.endTime = /* @__PURE__ */ new Date();
564
+ this.currentRun.durationMs = this.currentRun.endTime.getTime() - (this.currentRun.startTime?.getTime() || 0);
565
+ this.currentRun.passRate = this.currentRun.total > 0 ? this.currentRun.passed / this.currentRun.total * 100 : 0;
566
+ for (const reporter of this.reporters) {
567
+ await reporter.endRun(this.currentRun);
568
+ }
569
+ const run = this.currentRun;
570
+ this.currentRun = null;
571
+ return run;
572
+ }
573
+ /**
574
+ * Report a test result.
575
+ */
576
+ async reportTest(test) {
577
+ if (this.currentRun) {
578
+ this.currentRun.tests.push(test);
579
+ this.currentRun.total++;
580
+ switch (test.status) {
581
+ case "passed" /* PASSED */:
582
+ this.currentRun.passed++;
583
+ break;
584
+ case "failed" /* FAILED */:
585
+ this.currentRun.failed++;
586
+ break;
587
+ case "broken" /* BROKEN */:
588
+ this.currentRun.broken++;
589
+ break;
590
+ case "skipped" /* SKIPPED */:
591
+ this.currentRun.skipped++;
592
+ break;
593
+ }
594
+ }
595
+ for (const reporter of this.reporters) {
596
+ await reporter.reportTest(test);
597
+ }
598
+ }
599
+ /**
600
+ * Get the current test run.
601
+ */
602
+ getCurrentRun() {
603
+ return this.currentRun;
604
+ }
605
+ };
606
+ _QAgenticReporter.instance = null;
607
+ var QAgenticReporter = _QAgenticReporter;
608
+
609
+ // src/cypress/simple-setup.ts
610
+ function setupQAgentic(on, config) {
611
+ const projectName = process.env.QAGENTIC_PROJECT_NAME || config.projectId || "Cypress E2E Tests";
612
+ const environment = process.env.QAGENTIC_ENVIRONMENT || process.env.NODE_ENV || "e2e";
613
+ const apiUrl = process.env.QAGENTIC_API_URL || "http://localhost:8080";
614
+ configure({
615
+ projectName,
616
+ environment,
617
+ apiUrl,
618
+ outputDir: "./qagentic-results"
619
+ });
620
+ const reporter = QAgenticReporter.getInstance();
621
+ let currentRun = null;
622
+ on("before:run", async () => {
623
+ try {
624
+ currentRun = await reporter.startRun({
625
+ name: `cypress_${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "")}`,
626
+ projectName,
627
+ environment
628
+ });
629
+ console.log("[QAagentic] Test run started successfully");
630
+ } catch (error) {
631
+ console.warn("[QAagentic] Failed to start run:", error);
632
+ }
633
+ });
634
+ on("after:spec", async (_spec, results) => {
635
+ if (!results?.tests) return;
636
+ for (const test of results.tests) {
637
+ try {
638
+ const testResult = {
639
+ id: uuid.v4(),
640
+ name: test.title[test.title.length - 1],
641
+ fullName: test.title.join(" > "),
642
+ status: parseStatus(test.state),
643
+ durationMs: test.duration,
644
+ startTime: new Date(Date.now() - test.duration),
645
+ endTime: /* @__PURE__ */ new Date(),
646
+ labels: {
647
+ suite: test.title.slice(0, -1).join(" > "),
648
+ feature: test.title[0]
649
+ },
650
+ links: [],
651
+ parameters: {},
652
+ steps: [],
653
+ attachments: [],
654
+ filePath: results.spec.relative,
655
+ retryCount: 0,
656
+ isRetry: false,
657
+ isFlaky: false
658
+ };
659
+ if (test.err) {
660
+ testResult.errorMessage = test.err.message;
661
+ testResult.stackTrace = test.err.stack;
662
+ testResult.errorType = "AssertionError";
663
+ }
664
+ await reporter.reportTest(testResult);
665
+ } catch (error) {
666
+ console.warn("[QAagentic] Failed to report test:", error);
667
+ }
668
+ }
669
+ });
670
+ on("after:run", async () => {
671
+ try {
672
+ await reporter.endRun();
673
+ console.log("[QAagentic] Test run completed");
674
+ } catch (error) {
675
+ console.warn("[QAagentic] Failed to end run:", error);
676
+ }
677
+ });
678
+ }
679
+ var simple_setup_default = setupQAgentic;
680
+
681
+ exports.default = simple_setup_default;
682
+ exports.setupQAgentic = setupQAgentic;
683
+ //# sourceMappingURL=simple-setup.js.map
684
+ //# sourceMappingURL=simple-setup.js.map