@empiricalrun/reporter
Advanced tools
Comparing version 0.16.1 to 0.17.0
# @empiricalrun/reporter | ||
## 0.17.0 | ||
### Minor Changes | ||
- 28d91a9: feat: support tests-complete send message on slack | ||
## 0.16.1 | ||
@@ -4,0 +10,0 @@ |
@@ -15,2 +15,3 @@ import { BaseReportSource, Platform } from "../sources/base"; | ||
sendEndMessage(): Promise<void>; | ||
sendTestsCompleteMessage(): Promise<void>; | ||
sendStartMessage(): Promise<void>; | ||
@@ -17,0 +18,0 @@ sendMessageForError(): Promise<void>; |
@@ -47,2 +47,7 @@ "use strict"; | ||
} | ||
async sendTestsCompleteMessage() { | ||
if (this.prLink) { | ||
console.log("sendTestsCompleteMessage not implemented for DashboardReportSink"); | ||
} | ||
} | ||
async sendStartMessage() { | ||
@@ -49,0 +54,0 @@ if (this.prLink) { |
@@ -11,2 +11,3 @@ import { BaseReportSource } from "../sources/base"; | ||
sendMessageForError(): Promise<void>; | ||
sendTestsCompleteMessage(): Promise<void>; | ||
sendEndMessage(): Promise<void>; | ||
@@ -13,0 +14,0 @@ private buildCardMessage; |
@@ -84,2 +84,5 @@ "use strict"; | ||
} | ||
async sendTestsCompleteMessage() { | ||
console.log("sendTestsCompleteMessage not implemented for GoogleChatReportSink"); | ||
} | ||
async sendEndMessage() { | ||
@@ -86,0 +89,0 @@ const results = this.reportSource.resultsSummary(); |
@@ -12,3 +12,5 @@ import { BaseReportSource } from "../sources/base"; | ||
sendMessageForError(): Promise<void>; | ||
private testResultsMessage; | ||
sendEndMessage(): Promise<void>; | ||
sendTestsCompleteMessage(): Promise<void>; | ||
private send; | ||
@@ -15,0 +17,0 @@ private formatLink; |
@@ -44,3 +44,3 @@ "use strict"; | ||
}; | ||
await this.send({ message, messageType: "test-start" }); | ||
await this.send({ message, messageType: "run-start" }); | ||
} | ||
@@ -68,5 +68,5 @@ async sendMessageForError() { | ||
}; | ||
await this.send({ message, messageType: "test-error" }); | ||
await this.send({ message, messageType: "run-error" }); | ||
} | ||
async sendEndMessage() { | ||
testResultsMessage({ withReport, }) { | ||
const results = this.reportSource.resultsSummary(); | ||
@@ -79,4 +79,6 @@ const messageStatus = results.hasPassed ? "passed" : "failed"; | ||
color: results.hasPassed ? color.success : color.error, | ||
title: "Open test report", | ||
title_link: this.reportSource.reportLink(), | ||
...(withReport && { | ||
title: "Open test report", | ||
title_link: this.reportSource.reportLink(), | ||
}), | ||
fields: [ | ||
@@ -96,3 +98,5 @@ { | ||
short: true, | ||
value: `${results.totalTests} (${this.formatLink(this.reportSource.reportLink(), "view")})`, | ||
value: withReport | ||
? `${results.totalTests} (${this.formatLink(this.reportSource.reportLink(), "view")})` | ||
: String(results.totalTests), | ||
}, | ||
@@ -114,3 +118,5 @@ { | ||
short: true, | ||
value: `${results.flakyTests} (${this.formatLink(reportLink, "view")})`, | ||
value: withReport | ||
? `${results.flakyTests} (${this.formatLink(reportLink, "view")})` | ||
: String(results.flakyTests), | ||
}); | ||
@@ -122,3 +128,3 @@ } | ||
const failures = failedTestsWithLinks.map((f) => { | ||
if (f.link) { | ||
if (withReport && f.link) { | ||
return `${f.name} (${this.formatLink(f.link, "view")})`; | ||
@@ -143,3 +149,5 @@ } | ||
const reportLink = this.reportSource.reportLink({ status: "failed" }); | ||
messageStr = `${testsStr}\n${this.formatLink(reportLink, "View all")}`; | ||
messageStr = withReport | ||
? `${testsStr}\n${this.formatLink(reportLink, "View all")}` | ||
: testsStr; | ||
} | ||
@@ -153,4 +161,12 @@ //@ts-ignore | ||
} | ||
await this.send({ message, messageType: "test-end" }); | ||
return message; | ||
} | ||
async sendEndMessage() { | ||
const message = this.testResultsMessage({ withReport: true }); | ||
await this.send({ message, messageType: "run-end" }); | ||
} | ||
async sendTestsCompleteMessage() { | ||
const message = this.testResultsMessage({ withReport: false }); | ||
await this.send({ message, messageType: "tests-complete" }); | ||
} | ||
async send({ message, messageType, }) { | ||
@@ -157,0 +173,0 @@ const payload = { |
@@ -16,6 +16,8 @@ export declare enum WorkflowType { | ||
sendMessageForError(): Promise<void>; | ||
sendTestsCompleteMessage(): Promise<void>; | ||
} | ||
export declare enum MESSAGE_TYPE { | ||
START = "start", | ||
END = "end" | ||
END = "end", | ||
TESTS_COMPLETE = "tests-complete" | ||
} | ||
@@ -22,0 +24,0 @@ export declare enum REPORT_TYPE { |
@@ -13,2 +13,3 @@ "use strict"; | ||
MESSAGE_TYPE["END"] = "end"; | ||
MESSAGE_TYPE["TESTS_COMPLETE"] = "tests-complete"; | ||
})(MESSAGE_TYPE || (exports.MESSAGE_TYPE = MESSAGE_TYPE = {})); | ||
@@ -15,0 +16,0 @@ var REPORT_TYPE; |
@@ -61,20 +61,28 @@ "use strict"; | ||
} | ||
if (messageType === types_1.MESSAGE_TYPE.START) { | ||
await Promise.all(sinks.map((s) => s.sendStartMessage())); | ||
await dashboardSinkInstance.sendTestRunToDb("started"); | ||
} | ||
else if (messageType === types_1.MESSAGE_TYPE.END) { | ||
if (!(await reportSource.reportExists())) { | ||
await Promise.all(sinks.map((s) => s.sendMessageForError())); | ||
switch (messageType) { | ||
case types_1.MESSAGE_TYPE.START: { | ||
await Promise.all(sinks.map((s) => s.sendStartMessage())); | ||
await dashboardSinkInstance.sendTestRunToDb("started"); | ||
break; | ||
} | ||
else { | ||
await Promise.all(sinks.map((s) => s.sendEndMessage())); | ||
await dashboardSinkInstance.sendTestRunToDb("ended"); | ||
case types_1.MESSAGE_TYPE.TESTS_COMPLETE: { | ||
await Promise.all(sinks.map((s) => s.sendTestsCompleteMessage())); | ||
break; | ||
} | ||
case types_1.MESSAGE_TYPE.END: { | ||
if (!(await reportSource.reportExists())) { | ||
await Promise.all(sinks.map((s) => s.sendMessageForError())); | ||
} | ||
else { | ||
await Promise.all(sinks.map((s) => s.sendEndMessage())); | ||
await dashboardSinkInstance.sendTestRunToDb("ended"); | ||
} | ||
break; | ||
} | ||
default: { | ||
throw Error(`message type (first arg) must be "start", "tests-complete" or "end".`); | ||
} | ||
} | ||
else { | ||
throw Error(`message type (first arg) must be "start" or "end".`); | ||
} | ||
} | ||
} | ||
exports.TestRunWorkflow = TestRunWorkflow; |
{ | ||
"name": "@empiricalrun/reporter", | ||
"version": "0.16.1", | ||
"version": "0.17.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "registry": "https://registry.npmjs.org/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75016
1631