create runner with ChatGPT-Codex by using the AGENTS.md
Some checks failed
tests / test (push) Failing after 4s
Some checks failed
tests / test (push) Failing after 4s
This commit is contained in:
52
reporter/test_samurai_jest_reporter.js
Normal file
52
reporter/test_samurai_jest_reporter.js
Normal file
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user