qagentic-reporter 0.1.14 → 0.1.16

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.
@@ -1,5 +1,5 @@
1
1
  export { S as Severity, b as Status, c as Step, u as attach, x as attachJson, w as attachScreenshot, y as attachText, e as epic, f as feature, l as label, g as severity, s as step, d as story, t as tag } from '../attachments-B2zaEsD5.mjs';
2
- export { default as setupQAgentic } from './simple-setup.mjs';
2
+ export { setupQAgentic } from './simple-setup.mjs';
3
3
 
4
4
  /**
5
5
  * QAagentic Cypress Plugin
@@ -1,5 +1,5 @@
1
1
  export { S as Severity, b as Status, c as Step, u as attach, x as attachJson, w as attachScreenshot, y as attachText, e as epic, f as feature, l as label, g as severity, s as step, d as story, t as tag } from '../attachments-B2zaEsD5.js';
2
- export { default as setupQAgentic } from './simple-setup.js';
2
+ export { setupQAgentic } from './simple-setup.js';
3
3
 
4
4
  /**
5
5
  * QAagentic Cypress Plugin
@@ -456,18 +456,28 @@ var APIReporter = class {
456
456
  if (!this.config.api.enabled) return;
457
457
  await this.flushBatch();
458
458
  try {
459
- await axios__default.default.patch(
459
+ console.log("[APIReporter] Finalizing run with test counts:", {
460
+ total: run.total,
461
+ passed: run.passed,
462
+ failed: run.failed,
463
+ broken: run.broken,
464
+ skipped: run.skipped
465
+ });
466
+ const patchData = {
467
+ end_time: run.endTime?.toISOString(),
468
+ duration_ms: run.durationMs,
469
+ total: run.total,
470
+ passed: run.passed,
471
+ failed: run.failed,
472
+ broken: run.broken,
473
+ skipped: run.skipped,
474
+ status: "completed"
475
+ };
476
+ console.log("[APIReporter] PATCH to:", `${this.config.api.url}/api/v1/runs/${run.id}`);
477
+ console.log("[APIReporter] PATCH data:", patchData);
478
+ const response = await axios__default.default.patch(
460
479
  `${this.config.api.url}/api/v1/runs/${run.id}`,
461
- {
462
- end_time: run.endTime?.toISOString(),
463
- duration_ms: run.durationMs,
464
- total: run.total,
465
- passed: run.passed,
466
- failed: run.failed,
467
- broken: run.broken,
468
- skipped: run.skipped,
469
- status: "completed"
470
- },
480
+ patchData,
471
481
  {
472
482
  headers: {
473
483
  "Content-Type": "application/json",
@@ -476,8 +486,12 @@ var APIReporter = class {
476
486
  timeout: this.config.api.timeout
477
487
  }
478
488
  );
489
+ console.log("[APIReporter] Run finalized successfully:", response.status);
479
490
  } catch (error) {
480
- console.warn("Warning: Failed to finalize run with API:", error);
491
+ console.warn("[APIReporter] Failed to finalize run with API:");
492
+ console.warn(" Error:", error.message);
493
+ console.warn(" Status:", error.response?.status);
494
+ console.warn(" Data:", error.response?.data);
481
495
  }
482
496
  }
483
497
  async reportTest(test) {
@@ -879,94 +893,103 @@ function attachJson(data, name = "JSON Data") {
879
893
  function attachText(text, name = "Text") {
880
894
  return attach(text, name, "text/plain", "txt");
881
895
  }
882
- function setupQAgentic(on, config) {
883
- const projectName = process.env.QAGENTIC_PROJECT_NAME || config.projectId || "Cypress E2E Tests";
884
- const environment = process.env.QAGENTIC_ENVIRONMENT || process.env.NODE_ENV || "e2e";
885
- const apiUrl = process.env.QAGENTIC_API_URL || "http://localhost:8080";
886
- console.log("[QAagentic] Initializing with config:", { projectName, environment, apiUrl });
887
- configure({
888
- projectName,
889
- environment,
890
- apiUrl,
891
- outputDir: "./qagentic-results"
892
- });
893
- const reporter = QAgenticReporter.getInstance();
894
- let currentRun = null;
895
- console.log("[QAagentic] Reporter initialized, setting up hooks");
896
- (async () => {
896
+ var QAgenticCypressReporter = class {
897
+ constructor(config) {
898
+ this.currentRun = null;
899
+ this.stats = {
900
+ suites: 0,
901
+ tests: 0,
902
+ passes: 0,
903
+ pending: 0,
904
+ failures: 0,
905
+ start: /* @__PURE__ */ new Date(),
906
+ end: /* @__PURE__ */ new Date(),
907
+ duration: 0
908
+ };
909
+ this.projectName = process.env.QAGENTIC_PROJECT_NAME || config.projectId || "Cypress E2E Tests";
910
+ this.environment = process.env.QAGENTIC_ENVIRONMENT || process.env.NODE_ENV || "e2e";
911
+ const apiUrl = process.env.QAGENTIC_API_URL || "http://localhost:8080";
912
+ configure({
913
+ projectName: this.projectName,
914
+ environment: this.environment,
915
+ apiUrl,
916
+ outputDir: "./qagentic-results"
917
+ });
918
+ this.reporter = QAgenticReporter.getInstance();
919
+ this.stats.start = /* @__PURE__ */ new Date();
920
+ }
921
+ async onRunBegin() {
897
922
  try {
898
- console.log("[QAagentic] Starting test run immediately");
899
- currentRun = await reporter.startRun({
900
- name: `cypress_${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "")}`,
901
- projectName,
902
- environment
923
+ this.currentRun = await this.reporter.startRun({
924
+ name: this.projectName,
925
+ projectName: this.projectName,
926
+ environment: this.environment,
927
+ startTime: this.stats.start
903
928
  });
904
- console.log("[QAagentic] Test run started successfully:", currentRun?.id);
905
929
  } catch (error) {
906
930
  console.warn("[QAagentic] Failed to start run:", error);
907
931
  }
908
- })();
909
- on("after:spec", async (_spec, results) => {
932
+ }
933
+ async onTestEnd(test) {
934
+ if (!this.currentRun) return;
910
935
  try {
911
- console.log("[QAagentic] after:spec hook started for:", results.spec.relative);
912
- if (!results?.tests) {
913
- console.log("[QAagentic] No tests found in spec results");
914
- return;
915
- }
916
- for (const test of results.tests) {
917
- try {
918
- const testResult = {
919
- id: uuid.v4(),
920
- name: test.title[test.title.length - 1],
921
- fullName: test.title.join(" > "),
922
- status: parseStatus(test.state),
923
- durationMs: test.duration,
924
- startTime: new Date(Date.now() - test.duration),
925
- endTime: /* @__PURE__ */ new Date(),
926
- labels: {
927
- suite: test.title.slice(0, -1).join(" > "),
928
- feature: test.title[0]
929
- },
930
- links: [],
931
- parameters: {},
932
- steps: [],
933
- attachments: [],
934
- filePath: results.spec.relative,
935
- retryCount: 0,
936
- isRetry: false,
937
- isFlaky: false
938
- };
939
- if (test.err) {
940
- testResult.errorMessage = test.err.message;
941
- testResult.stackTrace = test.err.stack;
942
- testResult.errorType = "AssertionError";
943
- }
944
- console.log("[QAagentic] Reporting test:", testResult.name, "-", testResult.status);
945
- await reporter.reportTest(testResult);
946
- } catch (error) {
947
- console.warn("[QAagentic] Failed to report test:", error);
948
- }
936
+ const testResult = {
937
+ id: uuid.v4(),
938
+ name: test.title[test.title.length - 1],
939
+ fullName: test.title.join(" > "),
940
+ status: parseStatus(test.state),
941
+ durationMs: test.duration,
942
+ startTime: new Date(Date.now() - test.duration),
943
+ endTime: /* @__PURE__ */ new Date(),
944
+ labels: {
945
+ suite: test.title.slice(0, -1).join(" > "),
946
+ feature: test.title[0]
947
+ },
948
+ links: [],
949
+ parameters: {},
950
+ steps: [],
951
+ attachments: [],
952
+ filePath: test.invocationDetails?.relativeFile || "",
953
+ retryCount: 0,
954
+ isRetry: false,
955
+ isFlaky: false
956
+ };
957
+ if (test.err) {
958
+ testResult.errorMessage = test.err.message;
959
+ testResult.stackTrace = test.err.stack;
960
+ testResult.errorType = "AssertionError";
949
961
  }
950
- console.log("[QAagentic] after:spec hook completed");
962
+ this.stats.tests++;
963
+ if (test.state === "passed") this.stats.passes++;
964
+ if (test.state === "failed") this.stats.failures++;
965
+ if (test.state === "pending") this.stats.pending++;
966
+ await this.reporter.reportTest(testResult);
951
967
  } catch (error) {
952
- console.warn("[QAagentic] Error in after:spec hook:", error);
968
+ console.warn("[QAagentic] Failed to report test:", error);
953
969
  }
954
- });
955
- on("task", {
956
- qagentic_endRun: async () => {
957
- try {
958
- console.log("[QAagentic] Ending test run and flushing batch");
959
- await reporter.endRun();
960
- console.log("[QAagentic] Test run completed and results sent");
961
- await new Promise((resolve) => setTimeout(resolve, 2e3));
962
- console.log("[QAagentic] All operations completed");
963
- return null;
964
- } catch (error) {
965
- console.warn("[QAagentic] Failed to end run:", error);
966
- return null;
967
- }
970
+ }
971
+ async onRunEnd() {
972
+ if (!this.currentRun) return;
973
+ try {
974
+ this.stats.end = /* @__PURE__ */ new Date();
975
+ this.stats.duration = this.stats.end.getTime() - this.stats.start.getTime();
976
+ this.currentRun.endTime = this.stats.end;
977
+ this.currentRun.durationMs = this.stats.duration;
978
+ this.currentRun.total = this.stats.tests;
979
+ this.currentRun.passed = this.stats.passes;
980
+ this.currentRun.failed = this.stats.failures;
981
+ this.currentRun.skipped = this.stats.pending;
982
+ await this.reporter.endRun();
983
+ } catch (error) {
984
+ console.warn("[QAagentic] Failed to end run:", error);
968
985
  }
969
- });
986
+ }
987
+ };
988
+ function setupQAgentic(on, config) {
989
+ const reporter = new QAgenticCypressReporter(config);
990
+ on("before:run", () => reporter.onRunBegin());
991
+ on("test:after:run", (test) => reporter.onTestEnd(test));
992
+ on("after:run", () => reporter.onRunEnd());
970
993
  }
971
994
 
972
995
  // src/cypress/index.ts