qagentic-reporter 0.1.32 → 0.1.34
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.
- package/dist/cypress/index.js +58 -15
- package/dist/cypress/index.js.map +1 -1
- package/dist/cypress/index.mjs +58 -15
- package/dist/cypress/index.mjs.map +1 -1
- package/dist/cypress/simple-setup.js +58 -15
- package/dist/cypress/simple-setup.js.map +1 -1
- package/dist/cypress/simple-setup.mjs +58 -15
- package/dist/cypress/simple-setup.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cypress/index.mjs
CHANGED
|
@@ -911,6 +911,7 @@ var QAgenticCypressReporter = class {
|
|
|
911
911
|
end: /* @__PURE__ */ new Date(),
|
|
912
912
|
duration: 0
|
|
913
913
|
};
|
|
914
|
+
this.failedTestResults = [];
|
|
914
915
|
this.projectName = process.env.QAGENTIC_PROJECT_NAME || config.projectId || "Cypress E2E Tests";
|
|
915
916
|
this.environment = process.env.QAGENTIC_ENVIRONMENT || process.env.NODE_ENV || "e2e";
|
|
916
917
|
const apiUrl = process.env.QAGENTIC_API_URL || "http://localhost:8080";
|
|
@@ -978,10 +979,13 @@ var QAgenticCypressReporter = class {
|
|
|
978
979
|
const displayError = test.displayError;
|
|
979
980
|
if (errorInfo) {
|
|
980
981
|
testResult.errorMessage = errorInfo.message || "Test failed";
|
|
981
|
-
testResult.stackTrace = errorInfo.stack || errorInfo.toString();
|
|
982
|
+
testResult.stackTrace = errorInfo.stack || errorInfo.codeFrame || errorInfo.toString() || displayError || "";
|
|
982
983
|
testResult.errorType = errorInfo.name || "AssertionError";
|
|
983
984
|
} else if (displayError) {
|
|
984
985
|
testResult.errorMessage = displayError;
|
|
986
|
+
if (displayError.includes("\n")) {
|
|
987
|
+
testResult.stackTrace = displayError;
|
|
988
|
+
}
|
|
985
989
|
testResult.errorType = "AssertionError";
|
|
986
990
|
} else {
|
|
987
991
|
testResult.errorMessage = "Test assertion failed";
|
|
@@ -992,13 +996,51 @@ var QAgenticCypressReporter = class {
|
|
|
992
996
|
type: testResult.errorType,
|
|
993
997
|
hasStackTrace: !!testResult.stackTrace
|
|
994
998
|
});
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
999
|
+
this.failedTestResults.push({
|
|
1000
|
+
testResult,
|
|
1001
|
+
test
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
this.stats.tests++;
|
|
1005
|
+
if (test.state === "passed") this.stats.passes++;
|
|
1006
|
+
if (test.state === "failed") this.stats.failures++;
|
|
1007
|
+
if (test.state === "pending") this.stats.pending++;
|
|
1008
|
+
await this.reporter.reportTest(testResult);
|
|
1009
|
+
} catch (error) {
|
|
1010
|
+
console.warn("[QAagentic] Failed to report test:", error);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
async attachScreenshots() {
|
|
1014
|
+
console.log("[QAagentic] Attaching screenshots to failed tests");
|
|
1015
|
+
for (const { testResult, test } of this.failedTestResults) {
|
|
1016
|
+
if (test.invocationDetails?.relativeFile) {
|
|
1017
|
+
const testFileName = test.invocationDetails.relativeFile.replace(/\.ts$/, "");
|
|
1018
|
+
const testName = test.title[test.title.length - 1];
|
|
1019
|
+
const fullTestTitle = test.title.join(", ");
|
|
1020
|
+
const screenshotPaths = [
|
|
1021
|
+
// Mochawesome report assets location with full title
|
|
1022
|
+
path2.join(
|
|
1023
|
+
process.cwd(),
|
|
1024
|
+
"cypress/reports/assets",
|
|
1025
|
+
testFileName,
|
|
1026
|
+
`${fullTestTitle} -- ${testName} (failed).png`
|
|
1027
|
+
),
|
|
1028
|
+
// Alternative: without full title path
|
|
1029
|
+
path2.join(
|
|
1030
|
+
process.cwd(),
|
|
1031
|
+
"cypress/reports/assets",
|
|
1032
|
+
testFileName,
|
|
1033
|
+
`${testName} (failed).png`
|
|
1034
|
+
),
|
|
1035
|
+
// Legacy cypress/screenshots location
|
|
1036
|
+
path2.join(
|
|
998
1037
|
process.cwd(),
|
|
999
1038
|
"cypress/screenshots",
|
|
1000
|
-
`${testFileName} -- ${
|
|
1001
|
-
)
|
|
1039
|
+
`${testFileName} -- ${testName} (failed).png`
|
|
1040
|
+
)
|
|
1041
|
+
];
|
|
1042
|
+
let screenshotFound = false;
|
|
1043
|
+
for (const screenshotPath of screenshotPaths) {
|
|
1002
1044
|
console.log("[QAagentic] Looking for screenshot at:", screenshotPath);
|
|
1003
1045
|
if (fs2.existsSync(screenshotPath)) {
|
|
1004
1046
|
try {
|
|
@@ -1013,22 +1055,19 @@ var QAgenticCypressReporter = class {
|
|
|
1013
1055
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1014
1056
|
});
|
|
1015
1057
|
console.log("[QAagentic] Added screenshot attachment:", screenshotPath);
|
|
1058
|
+
screenshotFound = true;
|
|
1059
|
+
break;
|
|
1016
1060
|
} catch (err) {
|
|
1017
1061
|
console.warn("[QAagentic] Failed to read screenshot:", err);
|
|
1018
1062
|
}
|
|
1019
|
-
} else {
|
|
1020
|
-
console.log("[QAagentic] Screenshot not found at:", screenshotPath);
|
|
1021
1063
|
}
|
|
1022
1064
|
}
|
|
1065
|
+
if (!screenshotFound) {
|
|
1066
|
+
console.log("[QAagentic] No screenshots found for test:", testName);
|
|
1067
|
+
}
|
|
1023
1068
|
}
|
|
1024
|
-
this.stats.tests++;
|
|
1025
|
-
if (test.state === "passed") this.stats.passes++;
|
|
1026
|
-
if (test.state === "failed") this.stats.failures++;
|
|
1027
|
-
if (test.state === "pending") this.stats.pending++;
|
|
1028
|
-
await this.reporter.reportTest(testResult);
|
|
1029
|
-
} catch (error) {
|
|
1030
|
-
console.warn("[QAagentic] Failed to report test:", error);
|
|
1031
1069
|
}
|
|
1070
|
+
this.failedTestResults = [];
|
|
1032
1071
|
}
|
|
1033
1072
|
async finalizeRun() {
|
|
1034
1073
|
if (this.runFinalized || !this.currentRun) return;
|
|
@@ -1058,13 +1097,17 @@ var QAgenticCypressReporter = class {
|
|
|
1058
1097
|
};
|
|
1059
1098
|
function setupQAgentic(on, config) {
|
|
1060
1099
|
const reporter = new QAgenticCypressReporter(config);
|
|
1100
|
+
on("test:after:run", (test, runnable) => {
|
|
1101
|
+
});
|
|
1061
1102
|
on("after:spec", (_spec, results) => {
|
|
1062
1103
|
return (async () => {
|
|
1063
1104
|
if (!results?.tests) return;
|
|
1064
1105
|
try {
|
|
1106
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
1065
1107
|
for (const test of results.tests) {
|
|
1066
1108
|
await reporter.onTestEnd(test);
|
|
1067
1109
|
}
|
|
1110
|
+
await reporter.attachScreenshots();
|
|
1068
1111
|
await reporter.finalizeRun();
|
|
1069
1112
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
1070
1113
|
} catch (error) {
|