qagentic-reporter 0.1.15 → 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
@@ -893,94 +893,103 @@ function attachJson(data, name = "JSON Data") {
893
893
  function attachText(text, name = "Text") {
894
894
  return attach(text, name, "text/plain", "txt");
895
895
  }
896
- function setupQAgentic(on, config) {
897
- const projectName = process.env.QAGENTIC_PROJECT_NAME || config.projectId || "Cypress E2E Tests";
898
- const environment = process.env.QAGENTIC_ENVIRONMENT || process.env.NODE_ENV || "e2e";
899
- const apiUrl = process.env.QAGENTIC_API_URL || "http://localhost:8080";
900
- console.log("[QAagentic] Initializing with config:", { projectName, environment, apiUrl });
901
- configure({
902
- projectName,
903
- environment,
904
- apiUrl,
905
- outputDir: "./qagentic-results"
906
- });
907
- const reporter = QAgenticReporter.getInstance();
908
- let currentRun = null;
909
- console.log("[QAagentic] Reporter initialized, setting up hooks");
910
- (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() {
911
922
  try {
912
- console.log("[QAagentic] Starting test run immediately");
913
- currentRun = await reporter.startRun({
914
- name: `cypress_${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "")}`,
915
- projectName,
916
- 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
917
928
  });
918
- console.log("[QAagentic] Test run started successfully:", currentRun?.id);
919
929
  } catch (error) {
920
930
  console.warn("[QAagentic] Failed to start run:", error);
921
931
  }
922
- })();
923
- on("after:spec", async (_spec, results) => {
932
+ }
933
+ async onTestEnd(test) {
934
+ if (!this.currentRun) return;
924
935
  try {
925
- console.log("[QAagentic] after:spec hook started for:", results.spec.relative);
926
- if (!results?.tests) {
927
- console.log("[QAagentic] No tests found in spec results");
928
- return;
929
- }
930
- for (const test of results.tests) {
931
- try {
932
- const testResult = {
933
- id: uuid.v4(),
934
- name: test.title[test.title.length - 1],
935
- fullName: test.title.join(" > "),
936
- status: parseStatus(test.state),
937
- durationMs: test.duration,
938
- startTime: new Date(Date.now() - test.duration),
939
- endTime: /* @__PURE__ */ new Date(),
940
- labels: {
941
- suite: test.title.slice(0, -1).join(" > "),
942
- feature: test.title[0]
943
- },
944
- links: [],
945
- parameters: {},
946
- steps: [],
947
- attachments: [],
948
- filePath: results.spec.relative,
949
- retryCount: 0,
950
- isRetry: false,
951
- isFlaky: false
952
- };
953
- if (test.err) {
954
- testResult.errorMessage = test.err.message;
955
- testResult.stackTrace = test.err.stack;
956
- testResult.errorType = "AssertionError";
957
- }
958
- console.log("[QAagentic] Reporting test:", testResult.name, "-", testResult.status);
959
- await reporter.reportTest(testResult);
960
- } catch (error) {
961
- console.warn("[QAagentic] Failed to report test:", error);
962
- }
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";
963
961
  }
964
- 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);
965
967
  } catch (error) {
966
- console.warn("[QAagentic] Error in after:spec hook:", error);
968
+ console.warn("[QAagentic] Failed to report test:", error);
967
969
  }
968
- });
969
- on("task", {
970
- qagentic_endRun: async () => {
971
- try {
972
- console.log("[QAagentic] Ending test run and flushing batch");
973
- await reporter.endRun();
974
- console.log("[QAagentic] Test run completed and results sent");
975
- await new Promise((resolve) => setTimeout(resolve, 2e3));
976
- console.log("[QAagentic] All operations completed");
977
- return null;
978
- } catch (error) {
979
- console.warn("[QAagentic] Failed to end run:", error);
980
- return null;
981
- }
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);
982
985
  }
983
- });
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());
984
993
  }
985
994
 
986
995
  // src/cypress/index.ts