@empiricalrun/reporter
Advanced tools
Comparing version 0.20.6 to 0.20.7
# @empiricalrun/reporter | ||
## 0.20.7 | ||
### Patch Changes | ||
- 9d17374: fix: throw run-error when there is a top level error pw report | ||
- d78a90f: fix: remove redundant runLink param | ||
## 0.20.6 | ||
@@ -4,0 +11,0 @@ |
import { BaseReportSource } from "../sources/base"; | ||
import { ReportSink } from "../types"; | ||
export declare class SlackReportSink implements ReportSink { | ||
private runLink; | ||
private runId; | ||
@@ -9,3 +8,3 @@ private reportSource; | ||
private environmentSlug?; | ||
constructor(runLink: string, runId: string, // TODO: remove this once we remove it from message contents | ||
constructor(runId: string, // TODO: remove this once we remove it from message contents | ||
reportSource: BaseReportSource, projectName: string, environmentSlug?: string | undefined); | ||
@@ -12,0 +11,0 @@ sendStartMessage(): Promise<void>; |
@@ -7,3 +7,2 @@ "use strict"; | ||
class SlackReportSink { | ||
runLink; | ||
runId; | ||
@@ -13,5 +12,4 @@ reportSource; | ||
environmentSlug; | ||
constructor(runLink, runId, // TODO: remove this once we remove it from message contents | ||
constructor(runId, // TODO: remove this once we remove it from message contents | ||
reportSource, projectName, environmentSlug) { | ||
this.runLink = runLink; | ||
this.runId = runId; | ||
@@ -18,0 +16,0 @@ this.reportSource = reportSource; |
@@ -24,2 +24,3 @@ export type Results = { | ||
reportExists(): Promise<boolean>; | ||
hasRunFailed(): boolean; | ||
resultsSummary(): Results; | ||
@@ -26,0 +27,0 @@ failedTests(): FailedTestWithLink[]; |
@@ -16,2 +16,3 @@ import { BaseReportSource, FailedTestWithLink, Results } from "./base"; | ||
getTestIdForTestName(testName: string): string; | ||
hasRunFailed(): boolean; | ||
failedTests(): FailedTestWithLink[]; | ||
@@ -18,0 +19,0 @@ reportLink(filter?: PlaywrightReportFilter): string; |
@@ -53,2 +53,6 @@ "use strict"; | ||
} | ||
hasRunFailed() { | ||
const results = (0, utils_1.parseJsonReport)(this.srcFile); | ||
return results?.errors?.length > 0; | ||
} | ||
failedTests() { | ||
@@ -55,0 +59,0 @@ const results = (0, utils_1.parseJsonReport)(this.srcFile); |
import { JSONReportSpec, JSONReportSuite } from "@playwright/test/reporter"; | ||
export declare function parseJsonReport<T>(srcFile: string): T; | ||
/** | ||
* method to generate github action run link using `runId` and `repoName` | ||
* this is specific to the repos created under empirical-run org | ||
* @param repoName | ||
* @param runId | ||
* @returns | ||
*/ | ||
export declare function buildGhRunLink(repoName: string, runId: string): string; | ||
export declare function buildRepoName(projectName: string): string; | ||
@@ -12,0 +4,0 @@ export declare function getGhEvent(): Record<string, any> | undefined; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getFlattenedTestList = exports.getGhEventPrLink = exports.isRunningForAutomatedPR = exports.getGhEvent = exports.buildRepoName = exports.buildGhRunLink = exports.parseJsonReport = void 0; | ||
exports.getFlattenedTestList = exports.getGhEventPrLink = exports.isRunningForAutomatedPR = exports.getGhEvent = exports.buildRepoName = exports.parseJsonReport = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -13,13 +13,2 @@ function parseJsonReport(srcFile) { | ||
exports.parseJsonReport = parseJsonReport; | ||
/** | ||
* method to generate github action run link using `runId` and `repoName` | ||
* this is specific to the repos created under empirical-run org | ||
* @param repoName | ||
* @param runId | ||
* @returns | ||
*/ | ||
function buildGhRunLink(repoName, runId) { | ||
return `https://github.com/empirical-run/${repoName}-tests/actions/runs/${runId}`; | ||
} | ||
exports.buildGhRunLink = buildGhRunLink; | ||
function buildRepoName(projectName) { | ||
@@ -26,0 +15,0 @@ return `${projectName}-tests`; |
@@ -27,6 +27,5 @@ "use strict"; | ||
} | ||
const runLink = (0, utils_1.buildGhRunLink)(projectName, runId); | ||
let reportSource = new playwright_1.PlaywrightReportSource(projectName, runId); | ||
let sinks = []; | ||
sinks.push(new slack_1.SlackReportSink(runLink, runId, reportSource, projectName, environmentSlug)); | ||
sinks.push(new slack_1.SlackReportSink(runId, reportSource, projectName, environmentSlug)); | ||
const summaryReportUrl = reportSource.getSummaryReportUrl(); | ||
@@ -47,5 +46,9 @@ const isAutomatedPr = process.env.IS_AUTOMATED_PR || (0, utils_1.isRunningForAutomatedPR)(); | ||
case types_1.MESSAGE_TYPE.END: { | ||
if (!(await reportSource.reportExists())) { | ||
const reportNotGenerated = !(await reportSource.reportExists()); | ||
if (reportNotGenerated) { | ||
await Promise.all(sinks.map((s) => s.sendMessageForError())); | ||
} | ||
else if (reportSource.hasRunFailed()) { | ||
await Promise.all(sinks.map((s) => s.sendMessageForError())); | ||
} | ||
else { | ||
@@ -52,0 +55,0 @@ await Promise.all(sinks.map((s) => s.sendEndMessage())); |
{ | ||
"name": "@empiricalrun/reporter", | ||
"version": "0.20.6", | ||
"version": "0.20.7", | ||
"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
47800
855