qagentic-reporter 0.1.37 → 0.1.39

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.
@@ -939,7 +939,6 @@ var QAgenticCypressReporter = class {
939
939
  end: /* @__PURE__ */ new Date(),
940
940
  duration: 0
941
941
  };
942
- this.failedTestResults = [];
943
942
  this.pendingTests = [];
944
943
  this.projectName = process.env.QAGENTIC_PROJECT_NAME || config.projectId || "Cypress E2E Tests";
945
944
  this.environment = process.env.QAGENTIC_ENVIRONMENT || process.env.NODE_ENV || "e2e";
@@ -1025,85 +1024,73 @@ var QAgenticCypressReporter = class {
1025
1024
  type: testResult.errorType,
1026
1025
  hasStackTrace: !!testResult.stackTrace
1027
1026
  });
1028
- this.failedTestResults.push({
1029
- testResult,
1030
- test
1031
- });
1032
1027
  }
1033
1028
  this.stats.tests++;
1034
1029
  if (test.state === "passed") this.stats.passes++;
1035
1030
  if (test.state === "failed") this.stats.failures++;
1036
1031
  if (test.state === "pending") this.stats.pending++;
1037
- this.pendingTests.push(testResult);
1032
+ this.pendingTests.push({
1033
+ testResult,
1034
+ test
1035
+ });
1038
1036
  } catch (error) {
1039
1037
  console.warn("[QAagentic] Failed to report test:", error);
1040
1038
  }
1041
1039
  }
1042
1040
  async attachScreenshots() {
1043
1041
  console.log("[QAagentic] Attaching screenshots to pending tests, count:", this.pendingTests.length);
1044
- for (const testResult of this.pendingTests) {
1045
- const failedTest = this.failedTestResults.find((ft) => ft.testResult.id === testResult.id);
1046
- if (failedTest && failedTest.test.invocationDetails?.relativeFile) {
1047
- const test = failedTest.test;
1048
- const testFileName = test.invocationDetails.relativeFile.replace(/\.ts$/, "");
1049
- const testName = test.title[test.title.length - 1];
1050
- const fullTestTitle = test.title.join(", ");
1051
- const screenshotPaths = [
1052
- // Mochawesome report assets location with full title
1053
- path2__namespace.join(
1054
- process.cwd(),
1055
- "cypress/reports/assets",
1056
- testFileName,
1057
- `${fullTestTitle} -- ${testName} (failed).png`
1058
- ),
1059
- // Alternative: without full title path
1060
- path2__namespace.join(
1061
- process.cwd(),
1062
- "cypress/reports/assets",
1063
- testFileName,
1064
- `${testName} (failed).png`
1065
- ),
1066
- // Legacy cypress/screenshots location
1067
- path2__namespace.join(
1068
- process.cwd(),
1069
- "cypress/screenshots",
1070
- `${testFileName} -- ${testName} (failed).png`
1071
- )
1072
- ];
1073
- let screenshotFound = false;
1074
- for (const screenshotPath of screenshotPaths) {
1075
- console.log("[QAagentic] Looking for screenshot at:", screenshotPath);
1076
- if (fs2__namespace.existsSync(screenshotPath)) {
1077
- try {
1078
- const screenshotContent = fs2__namespace.readFileSync(screenshotPath);
1079
- const attachment = {
1080
- id: uuid.v4(),
1081
- name: "screenshot",
1082
- type: "image/png",
1083
- extension: "png",
1084
- content: screenshotContent.toString("base64"),
1085
- size: screenshotContent.length,
1086
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1087
- };
1088
- testResult.attachments.push(attachment);
1089
- console.log("[QAagentic] Added screenshot attachment:", screenshotPath);
1090
- screenshotFound = true;
1091
- break;
1092
- } catch (err) {
1093
- console.warn("[QAagentic] Failed to read screenshot:", err);
1094
- }
1042
+ for (const { testResult, test } of this.pendingTests) {
1043
+ if (test.state !== "failed" || !test.invocationDetails?.relativeFile) {
1044
+ continue;
1045
+ }
1046
+ const testFileName = test.invocationDetails.relativeFile.replace(/\.ts$/, "");
1047
+ const fullTestTitle = test.title.join(" -- ");
1048
+ const screenshotPaths = [
1049
+ // Mochawesome report assets location - most recent screenshot (no attempt number)
1050
+ path2__namespace.join(
1051
+ process.cwd(),
1052
+ "cypress/reports/assets",
1053
+ testFileName,
1054
+ `${fullTestTitle} (failed).png`
1055
+ ),
1056
+ // With attempt number (fallback)
1057
+ path2__namespace.join(
1058
+ process.cwd(),
1059
+ "cypress/reports/assets",
1060
+ testFileName,
1061
+ `${fullTestTitle} (failed) (attempt 1).png`
1062
+ )
1063
+ ];
1064
+ let screenshotFound = false;
1065
+ for (const screenshotPath of screenshotPaths) {
1066
+ if (fs2__namespace.existsSync(screenshotPath)) {
1067
+ try {
1068
+ const screenshotContent = fs2__namespace.readFileSync(screenshotPath);
1069
+ testResult.attachments.push({
1070
+ id: uuid.v4(),
1071
+ name: "screenshot",
1072
+ type: "image/png",
1073
+ extension: "png",
1074
+ content: screenshotContent.toString("base64"),
1075
+ size: screenshotContent.length,
1076
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1077
+ });
1078
+ console.log("[QAagentic] Added screenshot for:", fullTestTitle);
1079
+ screenshotFound = true;
1080
+ break;
1081
+ } catch (err) {
1082
+ console.warn("[QAagentic] Failed to read screenshot:", err);
1095
1083
  }
1096
1084
  }
1097
- if (!screenshotFound) {
1098
- console.log("[QAagentic] No screenshots found for test:", testName);
1099
- }
1085
+ }
1086
+ if (!screenshotFound) {
1087
+ console.log("[QAagentic] No screenshot found for:", fullTestTitle);
1100
1088
  }
1101
1089
  }
1102
- this.failedTestResults = [];
1103
1090
  }
1104
1091
  async sendPendingTests() {
1105
1092
  console.log("[QAagentic] Sending", this.pendingTests.length, "pending tests to API");
1106
- for (const testResult of this.pendingTests) {
1093
+ for (const { testResult } of this.pendingTests) {
1107
1094
  await this.reporter.reportTest(testResult);
1108
1095
  }
1109
1096
  this.pendingTests = [];