@bigbinary/neeto-playwright-reporter 1.1.0 → 1.2.1
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 +54 -19
- package/index.cjs.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +54 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare class MyReporter implements Reporter {
|
|
|
13
13
|
constructor(options: ReporterOptionParams);
|
|
14
14
|
onBegin: (config: FullConfig, rootSuite: Suite) => Promise<void>;
|
|
15
15
|
onTestBegin: ({ id, title }: TestCase, { retry }: TestResult) => Promise<void>;
|
|
16
|
-
onTestEnd: (
|
|
16
|
+
onTestEnd: (testCase: TestCase, { status, duration, errors, retry, attachments }: TestResult) => Promise<void>;
|
|
17
17
|
onEnd: ({ status, duration }: FullResult) => Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
|
package/index.js
CHANGED
|
@@ -18446,6 +18446,7 @@ const attemptsApi = { create: create$2, update: update$1 };
|
|
|
18446
18446
|
const ERRORS = {
|
|
18447
18447
|
onBegin: {
|
|
18448
18448
|
failedToGetCommitSha: "Failed to get current commit SHA.",
|
|
18449
|
+
failedToGetBranch: "Failed to get current branch.",
|
|
18449
18450
|
failedToGetCommitMessage: "Failed to get current commit message.",
|
|
18450
18451
|
failedToInitializeRun: "Failed to initialize run in reporter",
|
|
18451
18452
|
},
|
|
@@ -18455,23 +18456,32 @@ const ERRORS = {
|
|
|
18455
18456
|
onEnd: {
|
|
18456
18457
|
failedToReportRunStatus: "Failed to report run status",
|
|
18457
18458
|
},
|
|
18459
|
+
heartbeat: {
|
|
18460
|
+
stopped: "Run was stopped at the reporter",
|
|
18461
|
+
},
|
|
18458
18462
|
};
|
|
18459
18463
|
|
|
18460
18464
|
const MESSAGES = {
|
|
18461
18465
|
onBegin: {
|
|
18462
|
-
testStarted: "
|
|
18466
|
+
testStarted: "Run has started reporting to neetoPlaywrightReporter",
|
|
18463
18467
|
ciBuildId: (currentCiBuildId) => `CI BUILD ID: ${currentCiBuildId}`,
|
|
18464
18468
|
totalShards: (totalShards) => `Total shards: ${totalShards}`,
|
|
18465
18469
|
currentShard: (currentShard) => `Current shard: ${currentShard}`,
|
|
18466
18470
|
},
|
|
18471
|
+
onTestBegin: {
|
|
18472
|
+
startingTest: (titlePath) => `Starting ${titlePath}`,
|
|
18473
|
+
},
|
|
18474
|
+
onTestEnd: {
|
|
18475
|
+
reportedTest: (title) => `Reported ${title} to neetoPlaywrightReporter`,
|
|
18476
|
+
},
|
|
18467
18477
|
};
|
|
18468
18478
|
|
|
18469
18479
|
const consoleLogFormatted = {
|
|
18470
|
-
bold: (message) => console.log(
|
|
18471
|
-
dim: (message) => console.log(
|
|
18472
|
-
underline: (message) => console.log(
|
|
18473
|
-
invertBackground: (message) => console.log(
|
|
18474
|
-
hidden: (message) => console.log(
|
|
18480
|
+
bold: (message) => console.log("\x1b[1m", message, "\x1b[0m"),
|
|
18481
|
+
dim: (message) => console.log("\x1b[2m", message, "\x1b[0m"),
|
|
18482
|
+
underline: (message) => console.log("\x1b[4m", message, "\x1b[0m"),
|
|
18483
|
+
invertBackground: (message) => console.log("\x1b[7m", message, "\x1b[0m"),
|
|
18484
|
+
hidden: (message) => console.log("\x1b[8m", message, "\x1b[0m"),
|
|
18475
18485
|
error: (message) => console.log("\u001b[31m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18476
18486
|
warning: (message) => console.log("\u001b[33m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18477
18487
|
};
|
|
@@ -18494,6 +18504,15 @@ const createShardObject = ({ currentShard = 0, status = "running", duration = nu
|
|
|
18494
18504
|
});
|
|
18495
18505
|
const convertBufferToBlob = (buffer, contentType) => new Blob([buffer], { type: contentType });
|
|
18496
18506
|
|
|
18507
|
+
const create$1 = (payload) => axios.post(`${API_BASE_URL}/reporter/runs`, {
|
|
18508
|
+
run: payload,
|
|
18509
|
+
});
|
|
18510
|
+
const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}`, {
|
|
18511
|
+
run: payload,
|
|
18512
|
+
});
|
|
18513
|
+
const heartbeat = (ciBuildId) => axios.get(`${API_BASE_URL}/reporter/runs/${ciBuildId}/heartbeat`);
|
|
18514
|
+
const runsApi = { create: create$1, update, heartbeat };
|
|
18515
|
+
|
|
18497
18516
|
const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
|
|
18498
18517
|
const getCurrentCommitSha = () => executeCommandLine({
|
|
18499
18518
|
command: "git rev-parse HEAD",
|
|
@@ -18503,6 +18522,10 @@ const getCurrentCommitMessage = () => executeCommandLine({
|
|
|
18503
18522
|
command: "git show-branch --no-name HEAD",
|
|
18504
18523
|
messageOnError: ERRORS.onBegin.failedToGetCommitMessage,
|
|
18505
18524
|
});
|
|
18525
|
+
const getCurrentBranch = () => executeCommandLine({
|
|
18526
|
+
command: "git branch --show-current",
|
|
18527
|
+
messageOnError: ERRORS.onBegin.failedToGetBranch,
|
|
18528
|
+
});
|
|
18506
18529
|
const getInitializerData = ({ rootDir }, rootSuite) => rootSuite.allTests().map(test => {
|
|
18507
18530
|
var _a;
|
|
18508
18531
|
const { title, parent, id: history_id, location: { file }, } = test;
|
|
@@ -18512,6 +18535,15 @@ const getInitializerData = ({ rootDir }, rootSuite) => rootSuite.allTests().map(
|
|
|
18512
18535
|
const describe = getDescribePath({ titlePath, title, spec, project });
|
|
18513
18536
|
return { title, describe, project, spec, history_id };
|
|
18514
18537
|
});
|
|
18538
|
+
const sendHeartBeatSignal = async (ciBuildId) => {
|
|
18539
|
+
try {
|
|
18540
|
+
await runsApi.heartbeat(ciBuildId);
|
|
18541
|
+
}
|
|
18542
|
+
catch (error) {
|
|
18543
|
+
consoleLogFormatted.error(ERRORS.heartbeat.stopped);
|
|
18544
|
+
process.exit(1);
|
|
18545
|
+
}
|
|
18546
|
+
};
|
|
18515
18547
|
|
|
18516
18548
|
const setAuthHeaders = (projectKey) => {
|
|
18517
18549
|
var _a;
|
|
@@ -18528,14 +18560,6 @@ function initializeAxios({ projectKey, baseURL, }) {
|
|
|
18528
18560
|
setAuthHeaders(projectKey);
|
|
18529
18561
|
}
|
|
18530
18562
|
|
|
18531
|
-
const create$1 = (payload) => axios.post(`${API_BASE_URL}/reporter/runs`, {
|
|
18532
|
-
run: payload,
|
|
18533
|
-
});
|
|
18534
|
-
const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}`, {
|
|
18535
|
-
run: payload,
|
|
18536
|
-
});
|
|
18537
|
-
const runsApi = { create: create$1, update };
|
|
18538
|
-
|
|
18539
18563
|
const create = (ciBuildId, payload) => axios.post(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities`, {
|
|
18540
18564
|
test_entity: payload,
|
|
18541
18565
|
});
|
|
@@ -18550,6 +18574,7 @@ class MyReporter {
|
|
|
18550
18574
|
const runDetails = {
|
|
18551
18575
|
commit_id: getCurrentCommitSha(),
|
|
18552
18576
|
commit_name: getCurrentCommitMessage(),
|
|
18577
|
+
branch: getCurrentBranch(),
|
|
18553
18578
|
ci_build_id: this.ciBuildId,
|
|
18554
18579
|
configuration: config,
|
|
18555
18580
|
shards: createShardObject({ currentShard: shard === null || shard === void 0 ? void 0 : shard.current }),
|
|
@@ -18560,7 +18585,7 @@ class MyReporter {
|
|
|
18560
18585
|
}));
|
|
18561
18586
|
}
|
|
18562
18587
|
catch (error) {
|
|
18563
|
-
consoleLogFormatted.error(error);
|
|
18588
|
+
consoleLogFormatted.error(error.message);
|
|
18564
18589
|
throw new Error(ERRORS.onBegin.failedToInitializeRun);
|
|
18565
18590
|
}
|
|
18566
18591
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
@@ -18569,25 +18594,32 @@ class MyReporter {
|
|
|
18569
18594
|
consoleLogFormatted.dim(MESSAGES.onBegin.totalShards(shard.total));
|
|
18570
18595
|
consoleLogFormatted.dim(MESSAGES.onBegin.currentShard(shard.current));
|
|
18571
18596
|
}
|
|
18597
|
+
await sendHeartBeatSignal(this.ciBuildId);
|
|
18598
|
+
setInterval(async () => await sendHeartBeatSignal(this.ciBuildId), 60000);
|
|
18572
18599
|
this.attempts = attempts;
|
|
18573
18600
|
this.config = config;
|
|
18574
18601
|
this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
|
|
18575
18602
|
};
|
|
18576
18603
|
this.onTestBegin = async ({ id, title }, { retry }) => {
|
|
18604
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
|
|
18577
18605
|
try {
|
|
18578
18606
|
const formData = new FormData();
|
|
18579
18607
|
formData.append("attempt[status]", "running");
|
|
18608
|
+
formData.append("attempt[started_at]", new Date().toString());
|
|
18580
18609
|
retry === 0 &&
|
|
18581
18610
|
(await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData));
|
|
18582
18611
|
}
|
|
18583
18612
|
catch (error) {
|
|
18613
|
+
consoleLogFormatted.error(error.message);
|
|
18584
18614
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18585
|
-
console.log(error);
|
|
18586
18615
|
}
|
|
18587
18616
|
};
|
|
18588
|
-
this.onTestEnd = async (
|
|
18617
|
+
this.onTestEnd = async (testCase, { status, duration, errors, retry, attachments }) => {
|
|
18618
|
+
const { id, title, expectedStatus } = testCase;
|
|
18589
18619
|
try {
|
|
18590
18620
|
const testResult = {
|
|
18621
|
+
outcome: testCase.outcome(),
|
|
18622
|
+
expected_status: expectedStatus,
|
|
18591
18623
|
status,
|
|
18592
18624
|
duration,
|
|
18593
18625
|
log: errors.map(error => { var _a; return (_a = error.message) !== null && _a !== void 0 ? _a : ""; }).join("\n"),
|
|
@@ -18604,13 +18636,16 @@ class MyReporter {
|
|
|
18604
18636
|
Object.entries(testResult).map(([resultKey, resultValue]) => {
|
|
18605
18637
|
formData.append(`attempt[${resultKey}]`, resultValue.toString());
|
|
18606
18638
|
});
|
|
18639
|
+
retry !== 0 &&
|
|
18640
|
+
formData.append("attempt[started_at]", new Date().toString());
|
|
18607
18641
|
retry === 0
|
|
18608
18642
|
? await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData)
|
|
18609
18643
|
: await attemptsApi.create(this.ciBuildId, id, formData);
|
|
18644
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18610
18645
|
}
|
|
18611
18646
|
catch (error) {
|
|
18647
|
+
consoleLogFormatted.error(error.message);
|
|
18612
18648
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18613
|
-
console.log(error);
|
|
18614
18649
|
}
|
|
18615
18650
|
};
|
|
18616
18651
|
this.onEnd = async ({ status, duration }) => {
|
|
@@ -18624,7 +18659,7 @@ class MyReporter {
|
|
|
18624
18659
|
});
|
|
18625
18660
|
}
|
|
18626
18661
|
catch (error) {
|
|
18627
|
-
|
|
18662
|
+
consoleLogFormatted.error(error.message);
|
|
18628
18663
|
throw new Error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18629
18664
|
}
|
|
18630
18665
|
};
|