qagentic-reporter 0.1.36 → 0.1.38

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,83 +1024,80 @@ 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
- console.log("[QAagentic] Attaching screenshots to failed tests, count:", this.failedTestResults.length);
1044
- for (const { testResult, test } of this.failedTestResults) {
1045
- if (test.invocationDetails?.relativeFile) {
1046
- const testFileName = test.invocationDetails.relativeFile.replace(/\.ts$/, "");
1047
- const testName = test.title[test.title.length - 1];
1048
- const fullTestTitle = test.title.join(", ");
1049
- const screenshotPaths = [
1050
- // Mochawesome report assets location with full title
1051
- path2__namespace.join(
1052
- process.cwd(),
1053
- "cypress/reports/assets",
1054
- testFileName,
1055
- `${fullTestTitle} -- ${testName} (failed).png`
1056
- ),
1057
- // Alternative: without full title path
1058
- path2__namespace.join(
1059
- process.cwd(),
1060
- "cypress/reports/assets",
1061
- testFileName,
1062
- `${testName} (failed).png`
1063
- ),
1064
- // Legacy cypress/screenshots location
1065
- path2__namespace.join(
1066
- process.cwd(),
1067
- "cypress/screenshots",
1068
- `${testFileName} -- ${testName} (failed).png`
1069
- )
1070
- ];
1071
- let screenshotFound = false;
1072
- for (const screenshotPath of screenshotPaths) {
1073
- console.log("[QAagentic] Looking for screenshot at:", screenshotPath);
1074
- if (fs2__namespace.existsSync(screenshotPath)) {
1075
- try {
1076
- const screenshotContent = fs2__namespace.readFileSync(screenshotPath);
1077
- const attachment = {
1078
- id: uuid.v4(),
1079
- name: "screenshot",
1080
- type: "image/png",
1081
- extension: "png",
1082
- content: screenshotContent.toString("base64"),
1083
- size: screenshotContent.length,
1084
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1085
- };
1086
- testResult.attachments.push(attachment);
1087
- console.log("[QAagentic] Added screenshot attachment:", screenshotPath);
1088
- screenshotFound = true;
1089
- break;
1090
- } catch (err) {
1091
- console.warn("[QAagentic] Failed to read screenshot:", err);
1092
- }
1041
+ console.log("[QAagentic] Attaching screenshots to pending tests, count:", this.pendingTests.length);
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 testName = test.title[test.title.length - 1];
1048
+ const fullTestTitle = test.title.join(", ");
1049
+ const screenshotPaths = [
1050
+ // Mochawesome report assets location with full title
1051
+ path2__namespace.join(
1052
+ process.cwd(),
1053
+ "cypress/reports/assets",
1054
+ testFileName,
1055
+ `${fullTestTitle} -- ${testName} (failed).png`
1056
+ ),
1057
+ // Alternative: without full title path
1058
+ path2__namespace.join(
1059
+ process.cwd(),
1060
+ "cypress/reports/assets",
1061
+ testFileName,
1062
+ `${testName} (failed).png`
1063
+ ),
1064
+ // Legacy cypress/screenshots location
1065
+ path2__namespace.join(
1066
+ process.cwd(),
1067
+ "cypress/screenshots",
1068
+ `${testFileName} -- ${testName} (failed).png`
1069
+ )
1070
+ ];
1071
+ let screenshotFound = false;
1072
+ for (const screenshotPath of screenshotPaths) {
1073
+ if (fs2__namespace.existsSync(screenshotPath)) {
1074
+ try {
1075
+ const screenshotContent = fs2__namespace.readFileSync(screenshotPath);
1076
+ testResult.attachments.push({
1077
+ id: uuid.v4(),
1078
+ name: "screenshot",
1079
+ type: "image/png",
1080
+ extension: "png",
1081
+ content: screenshotContent.toString("base64"),
1082
+ size: screenshotContent.length,
1083
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1084
+ });
1085
+ console.log("[QAagentic] Added screenshot for:", testName);
1086
+ screenshotFound = true;
1087
+ break;
1088
+ } catch (err) {
1089
+ console.warn("[QAagentic] Failed to read screenshot:", err);
1093
1090
  }
1094
1091
  }
1095
- if (!screenshotFound) {
1096
- console.log("[QAagentic] No screenshots found for test:", testName);
1097
- }
1092
+ }
1093
+ if (!screenshotFound) {
1094
+ console.log("[QAagentic] No screenshot found for:", testName);
1098
1095
  }
1099
1096
  }
1100
- this.failedTestResults = [];
1101
1097
  }
1102
1098
  async sendPendingTests() {
1103
1099
  console.log("[QAagentic] Sending", this.pendingTests.length, "pending tests to API");
1104
- for (const testResult of this.pendingTests) {
1100
+ for (const { testResult } of this.pendingTests) {
1105
1101
  await this.reporter.reportTest(testResult);
1106
1102
  }
1107
1103
  this.pendingTests = [];