@bigbinary/neeto-playwright-reporter 1.1.0 → 1.2.0
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 +41 -18
- package/index.cjs.js.map +1 -1
- package/index.js +41 -18
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -18473,23 +18473,32 @@ const ERRORS = {
|
|
|
18473
18473
|
onEnd: {
|
|
18474
18474
|
failedToReportRunStatus: "Failed to report run status",
|
|
18475
18475
|
},
|
|
18476
|
+
heartbeat: {
|
|
18477
|
+
stopped: "Run was stopped at the reporter",
|
|
18478
|
+
},
|
|
18476
18479
|
};
|
|
18477
18480
|
|
|
18478
18481
|
const MESSAGES = {
|
|
18479
18482
|
onBegin: {
|
|
18480
|
-
testStarted: "
|
|
18483
|
+
testStarted: "Run has started reporting to neetoPlaywrightReporter",
|
|
18481
18484
|
ciBuildId: (currentCiBuildId) => `CI BUILD ID: ${currentCiBuildId}`,
|
|
18482
18485
|
totalShards: (totalShards) => `Total shards: ${totalShards}`,
|
|
18483
18486
|
currentShard: (currentShard) => `Current shard: ${currentShard}`,
|
|
18484
18487
|
},
|
|
18488
|
+
onTestBegin: {
|
|
18489
|
+
startingTest: (titlePath) => `Starting ${titlePath}`,
|
|
18490
|
+
},
|
|
18491
|
+
onTestEnd: {
|
|
18492
|
+
reportedTest: (title) => `Reported ${title} to neetoPlaywrightReporter`,
|
|
18493
|
+
},
|
|
18485
18494
|
};
|
|
18486
18495
|
|
|
18487
18496
|
const consoleLogFormatted = {
|
|
18488
|
-
bold: (message) => console.log(
|
|
18489
|
-
dim: (message) => console.log(
|
|
18490
|
-
underline: (message) => console.log(
|
|
18491
|
-
invertBackground: (message) => console.log(
|
|
18492
|
-
hidden: (message) => console.log(
|
|
18497
|
+
bold: (message) => console.log("\x1b[1m", message, "\x1b[0m"),
|
|
18498
|
+
dim: (message) => console.log("\x1b[2m", message, "\x1b[0m"),
|
|
18499
|
+
underline: (message) => console.log("\x1b[4m", message, "\x1b[0m"),
|
|
18500
|
+
invertBackground: (message) => console.log("\x1b[7m", message, "\x1b[0m"),
|
|
18501
|
+
hidden: (message) => console.log("\x1b[8m", message, "\x1b[0m"),
|
|
18493
18502
|
error: (message) => console.log("\u001b[31m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18494
18503
|
warning: (message) => console.log("\u001b[33m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18495
18504
|
};
|
|
@@ -18512,6 +18521,15 @@ const createShardObject = ({ currentShard = 0, status = "running", duration = nu
|
|
|
18512
18521
|
});
|
|
18513
18522
|
const convertBufferToBlob = (buffer, contentType) => new Blob([buffer], { type: contentType });
|
|
18514
18523
|
|
|
18524
|
+
const create$1 = (payload) => axios.post(`${API_BASE_URL}/reporter/runs`, {
|
|
18525
|
+
run: payload,
|
|
18526
|
+
});
|
|
18527
|
+
const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}`, {
|
|
18528
|
+
run: payload,
|
|
18529
|
+
});
|
|
18530
|
+
const heartbeat = (ciBuildId) => axios.get(`${API_BASE_URL}/reporter/runs/${ciBuildId}/heartbeat`);
|
|
18531
|
+
const runsApi = { create: create$1, update, heartbeat };
|
|
18532
|
+
|
|
18515
18533
|
const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
|
|
18516
18534
|
const getCurrentCommitSha = () => executeCommandLine({
|
|
18517
18535
|
command: "git rev-parse HEAD",
|
|
@@ -18530,6 +18548,15 @@ const getInitializerData = ({ rootDir }, rootSuite) => rootSuite.allTests().map(
|
|
|
18530
18548
|
const describe = getDescribePath({ titlePath, title, spec, project });
|
|
18531
18549
|
return { title, describe, project, spec, history_id };
|
|
18532
18550
|
});
|
|
18551
|
+
const sendHeartBeatSignal = async (ciBuildId) => {
|
|
18552
|
+
try {
|
|
18553
|
+
await runsApi.heartbeat(ciBuildId);
|
|
18554
|
+
}
|
|
18555
|
+
catch (error) {
|
|
18556
|
+
consoleLogFormatted.error(ERRORS.heartbeat.stopped);
|
|
18557
|
+
process.exit(1);
|
|
18558
|
+
}
|
|
18559
|
+
};
|
|
18533
18560
|
|
|
18534
18561
|
const setAuthHeaders = (projectKey) => {
|
|
18535
18562
|
var _a;
|
|
@@ -18546,14 +18573,6 @@ function initializeAxios({ projectKey, baseURL, }) {
|
|
|
18546
18573
|
setAuthHeaders(projectKey);
|
|
18547
18574
|
}
|
|
18548
18575
|
|
|
18549
|
-
const create$1 = (payload) => axios.post(`${API_BASE_URL}/reporter/runs`, {
|
|
18550
|
-
run: payload,
|
|
18551
|
-
});
|
|
18552
|
-
const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}`, {
|
|
18553
|
-
run: payload,
|
|
18554
|
-
});
|
|
18555
|
-
const runsApi = { create: create$1, update };
|
|
18556
|
-
|
|
18557
18576
|
const create = (ciBuildId, payload) => axios.post(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities`, {
|
|
18558
18577
|
test_entity: payload,
|
|
18559
18578
|
});
|
|
@@ -18578,7 +18597,7 @@ class MyReporter {
|
|
|
18578
18597
|
}));
|
|
18579
18598
|
}
|
|
18580
18599
|
catch (error) {
|
|
18581
|
-
consoleLogFormatted.error(error);
|
|
18600
|
+
consoleLogFormatted.error(error.message);
|
|
18582
18601
|
throw new Error(ERRORS.onBegin.failedToInitializeRun);
|
|
18583
18602
|
}
|
|
18584
18603
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
@@ -18587,11 +18606,14 @@ class MyReporter {
|
|
|
18587
18606
|
consoleLogFormatted.dim(MESSAGES.onBegin.totalShards(shard.total));
|
|
18588
18607
|
consoleLogFormatted.dim(MESSAGES.onBegin.currentShard(shard.current));
|
|
18589
18608
|
}
|
|
18609
|
+
await sendHeartBeatSignal(this.ciBuildId);
|
|
18610
|
+
setInterval(async () => await sendHeartBeatSignal(this.ciBuildId), 60000);
|
|
18590
18611
|
this.attempts = attempts;
|
|
18591
18612
|
this.config = config;
|
|
18592
18613
|
this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
|
|
18593
18614
|
};
|
|
18594
18615
|
this.onTestBegin = async ({ id, title }, { retry }) => {
|
|
18616
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
|
|
18595
18617
|
try {
|
|
18596
18618
|
const formData = new FormData();
|
|
18597
18619
|
formData.append("attempt[status]", "running");
|
|
@@ -18599,8 +18621,8 @@ class MyReporter {
|
|
|
18599
18621
|
(await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData));
|
|
18600
18622
|
}
|
|
18601
18623
|
catch (error) {
|
|
18624
|
+
consoleLogFormatted.error(error.message);
|
|
18602
18625
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18603
|
-
console.log(error);
|
|
18604
18626
|
}
|
|
18605
18627
|
};
|
|
18606
18628
|
this.onTestEnd = async ({ id, title }, { status, duration, errors, retry, attachments }) => {
|
|
@@ -18625,10 +18647,11 @@ class MyReporter {
|
|
|
18625
18647
|
retry === 0
|
|
18626
18648
|
? await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData)
|
|
18627
18649
|
: await attemptsApi.create(this.ciBuildId, id, formData);
|
|
18650
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18628
18651
|
}
|
|
18629
18652
|
catch (error) {
|
|
18653
|
+
consoleLogFormatted.error(error.message);
|
|
18630
18654
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18631
|
-
console.log(error);
|
|
18632
18655
|
}
|
|
18633
18656
|
};
|
|
18634
18657
|
this.onEnd = async ({ status, duration }) => {
|
|
@@ -18642,7 +18665,7 @@ class MyReporter {
|
|
|
18642
18665
|
});
|
|
18643
18666
|
}
|
|
18644
18667
|
catch (error) {
|
|
18645
|
-
|
|
18668
|
+
consoleLogFormatted.error(error.message);
|
|
18646
18669
|
throw new Error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18647
18670
|
}
|
|
18648
18671
|
};
|