@bigbinary/neeto-playwright-reporter 1.3.7 → 1.3.9
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/index.cjs.js +25 -5
- package/index.cjs.js.map +1 -1
- package/index.d.ts +3 -0
- package/index.js +25 -5
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface ReporterOptionParams {
|
|
|
5
5
|
baseURL: string;
|
|
6
6
|
apiKey: string;
|
|
7
7
|
ciBuildId: string;
|
|
8
|
+
tags: string[] | string;
|
|
8
9
|
}
|
|
9
10
|
declare class MyReporter implements Reporter {
|
|
10
11
|
attempts: Record<string, Record<string, string>>;
|
|
@@ -15,6 +16,8 @@ declare class MyReporter implements Reporter {
|
|
|
15
16
|
testResultCalls: Promise<unknown>[];
|
|
16
17
|
totalTestCount: number;
|
|
17
18
|
reportedTestCount: number;
|
|
19
|
+
tags: string[] | string;
|
|
20
|
+
unreportedAttemptCount: number;
|
|
18
21
|
constructor(options: ReporterOptionParams);
|
|
19
22
|
onBegin: (config: FullConfig, rootSuite: Suite) => Promise<void>;
|
|
20
23
|
onTestBegin: ({ id, title }: TestCase, { retry }: TestResult) => Promise<void>;
|
package/index.js
CHANGED
|
@@ -18453,6 +18453,7 @@ const ERRORS = {
|
|
|
18453
18453
|
onBegin: {
|
|
18454
18454
|
noTestsToReport: "No tests to report",
|
|
18455
18455
|
failedToGetCommitSha: "Failed to get current commit SHA.",
|
|
18456
|
+
failedToGetAuthor: "Failed to get current author.",
|
|
18456
18457
|
failedToGetBranch: "Failed to get current branch.",
|
|
18457
18458
|
failedToGetCommitMessage: "Failed to get current commit message.",
|
|
18458
18459
|
failedToInitializeRun: "Failed to initialize run in reporter",
|
|
@@ -18470,7 +18471,7 @@ const ERRORS = {
|
|
|
18470
18471
|
|
|
18471
18472
|
const MESSAGES = {
|
|
18472
18473
|
onBegin: {
|
|
18473
|
-
testStarted: "Run has started reporting to
|
|
18474
|
+
testStarted: "Run has started reporting to neetoPlaydash",
|
|
18474
18475
|
ciBuildId: (currentCiBuildId) => `CI BUILD ID: ${currentCiBuildId}`,
|
|
18475
18476
|
totalShards: (totalShards) => `Total shards: ${totalShards}`,
|
|
18476
18477
|
currentShard: (currentShard) => `Current shard: ${currentShard}`,
|
|
@@ -18481,6 +18482,9 @@ const MESSAGES = {
|
|
|
18481
18482
|
onTestEnd: {
|
|
18482
18483
|
reportedTest: (title) => `Reported ${title} to neetoPlaywrightReporter`,
|
|
18483
18484
|
},
|
|
18485
|
+
onEnd: {
|
|
18486
|
+
runReported: "Run completed and reported to neetoPlaydash 🎉",
|
|
18487
|
+
},
|
|
18484
18488
|
};
|
|
18485
18489
|
|
|
18486
18490
|
const consoleLogFormatted = {
|
|
@@ -18539,6 +18543,10 @@ const getCurrentBranch = () => executeCommandLine({
|
|
|
18539
18543
|
command: "git branch --show-current",
|
|
18540
18544
|
messageOnError: ERRORS.onBegin.failedToGetBranch,
|
|
18541
18545
|
});
|
|
18546
|
+
const getCurrentAuthor = () => executeCommandLine({
|
|
18547
|
+
command: "git show -s --format='%an' HEAD",
|
|
18548
|
+
messageOnError: ERRORS.onBegin.failedToGetBranch,
|
|
18549
|
+
});
|
|
18542
18550
|
const getInitializerData = ({ rootDir }, rootSuite) => rootSuite.allTests().map(test => {
|
|
18543
18551
|
var _a;
|
|
18544
18552
|
const { title, parent, id: history_id, location: { file }, } = test;
|
|
@@ -18592,7 +18600,9 @@ class MyReporter {
|
|
|
18592
18600
|
const runDetails = {
|
|
18593
18601
|
commit_id: getCurrentCommitSha(),
|
|
18594
18602
|
commit_name: getCurrentCommitMessage(),
|
|
18603
|
+
author: getCurrentAuthor(),
|
|
18595
18604
|
branch: getCurrentBranch(),
|
|
18605
|
+
tags: typeof this.tags === "string" ? this.tags.split(",") : this.tags,
|
|
18596
18606
|
ci_build_id: this.ciBuildId,
|
|
18597
18607
|
configuration: config,
|
|
18598
18608
|
shards: createShardObject({ currentShard: shard === null || shard === void 0 ? void 0 : shard.current }),
|
|
@@ -18620,6 +18630,7 @@ class MyReporter {
|
|
|
18620
18630
|
};
|
|
18621
18631
|
this.onTestBegin = async ({ id, title }, { retry }) => {
|
|
18622
18632
|
var _a, _b;
|
|
18633
|
+
this.unreportedAttemptCount++;
|
|
18623
18634
|
consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
|
|
18624
18635
|
try {
|
|
18625
18636
|
this.retryAttemptStartedAt = new Date();
|
|
@@ -18664,7 +18675,9 @@ class MyReporter {
|
|
|
18664
18675
|
videos: [],
|
|
18665
18676
|
traces: [],
|
|
18666
18677
|
completed_at: completedAt.toString(),
|
|
18667
|
-
error_snippet:
|
|
18678
|
+
error_snippet: errorLocation
|
|
18679
|
+
? `# ${errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.file} (${errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line}:${errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.column}) \n\n\n ${error === null || error === void 0 ? void 0 : error.snippet}`
|
|
18680
|
+
: null,
|
|
18668
18681
|
};
|
|
18669
18682
|
consoleLogFormatted.underline(title);
|
|
18670
18683
|
await Promise.all(attachments.map(async ({ name, path, body, contentType, }) => {
|
|
@@ -18684,21 +18697,23 @@ class MyReporter {
|
|
|
18684
18697
|
while (!this.attempts[id][retry])
|
|
18685
18698
|
await waitUntilTimeout(100);
|
|
18686
18699
|
this.testResultCalls.push(attemptsApi.update(this.ciBuildId, id, this.attempts[id][retry], testResult));
|
|
18687
|
-
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18688
18700
|
}
|
|
18689
18701
|
catch (error) {
|
|
18690
18702
|
consoleLogFormatted.error(error.message);
|
|
18691
18703
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18692
18704
|
}
|
|
18693
18705
|
finally {
|
|
18706
|
+
this.unreportedAttemptCount--;
|
|
18694
18707
|
retry === 0 && this.reportedTestCount++;
|
|
18708
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18695
18709
|
}
|
|
18696
18710
|
};
|
|
18697
18711
|
this.onEnd = async ({ status, duration }) => {
|
|
18698
18712
|
try {
|
|
18699
|
-
|
|
18700
|
-
|
|
18713
|
+
while (this.totalTestCount !== this.reportedTestCount &&
|
|
18714
|
+
this.unreportedAttemptCount !== 0)
|
|
18701
18715
|
await waitUntilTimeout(100);
|
|
18716
|
+
await Promise.allSettled(this.testResultCalls);
|
|
18702
18717
|
await runsApi.update(this.ciBuildId, {
|
|
18703
18718
|
shards: createShardObject({
|
|
18704
18719
|
currentShard: this.currentShard,
|
|
@@ -18711,14 +18726,19 @@ class MyReporter {
|
|
|
18711
18726
|
consoleLogFormatted.error(error.message);
|
|
18712
18727
|
throw new Error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18713
18728
|
}
|
|
18729
|
+
finally {
|
|
18730
|
+
consoleLogFormatted.invertBackground(MESSAGES.onEnd.runReported);
|
|
18731
|
+
}
|
|
18714
18732
|
};
|
|
18715
18733
|
initializeAxios(options);
|
|
18716
18734
|
this.attempts = {};
|
|
18735
|
+
this.tags = options.tags;
|
|
18717
18736
|
this.ciBuildId = options.ciBuildId;
|
|
18718
18737
|
this.retryAttemptStartedAt = new Date();
|
|
18719
18738
|
this.testResultCalls = [];
|
|
18720
18739
|
this.totalTestCount = 0;
|
|
18721
18740
|
this.reportedTestCount = 0;
|
|
18741
|
+
this.unreportedAttemptCount = 0;
|
|
18722
18742
|
process.on("unhandledRejection", error => {
|
|
18723
18743
|
var _a;
|
|
18724
18744
|
consoleLogFormatted.error((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : JSON.stringify(error));
|