Files
test-samurai-jest-runner/reporter/test_samurai_jest_reporter.js
M.Schirmer b70d26256c
Some checks failed
tests / test (push) Failing after 4s
create runner with ChatGPT-Codex by using the AGENTS.md
2026-01-03 14:53:56 +01:00

53 lines
1.6 KiB
JavaScript

class TestSamuraiJestReporter {
constructor(_globalConfig, _options) {}
onTestCaseResult(test, testCaseResult) {
const name = this.buildListingName(testCaseResult);
const jestName = this.buildJestName(testCaseResult);
const payload = {
name,
jestName,
status: testCaseResult.status,
file: test && test.path ? test.path : null,
location: testCaseResult.location || null,
output: this.buildOutput(testCaseResult),
};
process.stdout.write(`TSAMURAI_RESULT ${JSON.stringify(payload)}\n`);
}
buildListingName(testCaseResult) {
const ancestors = Array.isArray(testCaseResult.ancestorTitles)
? testCaseResult.ancestorTitles
: [];
const title = testCaseResult.title ? String(testCaseResult.title) : "";
return [...ancestors, title].filter(Boolean).join("/");
}
buildJestName(testCaseResult) {
const ancestors = Array.isArray(testCaseResult.ancestorTitles)
? testCaseResult.ancestorTitles
: [];
const title = testCaseResult.title ? String(testCaseResult.title) : "";
return [...ancestors, title].filter(Boolean).join(" ");
}
buildOutput(testCaseResult) {
const lines = [];
const failures = Array.isArray(testCaseResult.failureMessages)
? testCaseResult.failureMessages
: [];
failures.forEach((message) => {
if (typeof message === "string" && message.length > 0) {
message.split("\n").forEach((line) => {
if (line !== "") {
lines.push(line);
}
});
}
});
return lines;
}
}
module.exports = TestSamuraiJestReporter;