@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.js
CHANGED
|
@@ -18455,23 +18455,32 @@ const ERRORS = {
|
|
|
18455
18455
|
onEnd: {
|
|
18456
18456
|
failedToReportRunStatus: "Failed to report run status",
|
|
18457
18457
|
},
|
|
18458
|
+
heartbeat: {
|
|
18459
|
+
stopped: "Run was stopped at the reporter",
|
|
18460
|
+
},
|
|
18458
18461
|
};
|
|
18459
18462
|
|
|
18460
18463
|
const MESSAGES = {
|
|
18461
18464
|
onBegin: {
|
|
18462
|
-
testStarted: "
|
|
18465
|
+
testStarted: "Run has started reporting to neetoPlaywrightReporter",
|
|
18463
18466
|
ciBuildId: (currentCiBuildId) => `CI BUILD ID: ${currentCiBuildId}`,
|
|
18464
18467
|
totalShards: (totalShards) => `Total shards: ${totalShards}`,
|
|
18465
18468
|
currentShard: (currentShard) => `Current shard: ${currentShard}`,
|
|
18466
18469
|
},
|
|
18470
|
+
onTestBegin: {
|
|
18471
|
+
startingTest: (titlePath) => `Starting ${titlePath}`,
|
|
18472
|
+
},
|
|
18473
|
+
onTestEnd: {
|
|
18474
|
+
reportedTest: (title) => `Reported ${title} to neetoPlaywrightReporter`,
|
|
18475
|
+
},
|
|
18467
18476
|
};
|
|
18468
18477
|
|
|
18469
18478
|
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(
|
|
18479
|
+
bold: (message) => console.log("\x1b[1m", message, "\x1b[0m"),
|
|
18480
|
+
dim: (message) => console.log("\x1b[2m", message, "\x1b[0m"),
|
|
18481
|
+
underline: (message) => console.log("\x1b[4m", message, "\x1b[0m"),
|
|
18482
|
+
invertBackground: (message) => console.log("\x1b[7m", message, "\x1b[0m"),
|
|
18483
|
+
hidden: (message) => console.log("\x1b[8m", message, "\x1b[0m"),
|
|
18475
18484
|
error: (message) => console.log("\u001b[31m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18476
18485
|
warning: (message) => console.log("\u001b[33m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18477
18486
|
};
|
|
@@ -18494,6 +18503,15 @@ const createShardObject = ({ currentShard = 0, status = "running", duration = nu
|
|
|
18494
18503
|
});
|
|
18495
18504
|
const convertBufferToBlob = (buffer, contentType) => new Blob([buffer], { type: contentType });
|
|
18496
18505
|
|
|
18506
|
+
const create$1 = (payload) => axios.post(`${API_BASE_URL}/reporter/runs`, {
|
|
18507
|
+
run: payload,
|
|
18508
|
+
});
|
|
18509
|
+
const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}`, {
|
|
18510
|
+
run: payload,
|
|
18511
|
+
});
|
|
18512
|
+
const heartbeat = (ciBuildId) => axios.get(`${API_BASE_URL}/reporter/runs/${ciBuildId}/heartbeat`);
|
|
18513
|
+
const runsApi = { create: create$1, update, heartbeat };
|
|
18514
|
+
|
|
18497
18515
|
const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
|
|
18498
18516
|
const getCurrentCommitSha = () => executeCommandLine({
|
|
18499
18517
|
command: "git rev-parse HEAD",
|
|
@@ -18512,6 +18530,15 @@ const getInitializerData = ({ rootDir }, rootSuite) => rootSuite.allTests().map(
|
|
|
18512
18530
|
const describe = getDescribePath({ titlePath, title, spec, project });
|
|
18513
18531
|
return { title, describe, project, spec, history_id };
|
|
18514
18532
|
});
|
|
18533
|
+
const sendHeartBeatSignal = async (ciBuildId) => {
|
|
18534
|
+
try {
|
|
18535
|
+
await runsApi.heartbeat(ciBuildId);
|
|
18536
|
+
}
|
|
18537
|
+
catch (error) {
|
|
18538
|
+
consoleLogFormatted.error(ERRORS.heartbeat.stopped);
|
|
18539
|
+
process.exit(1);
|
|
18540
|
+
}
|
|
18541
|
+
};
|
|
18515
18542
|
|
|
18516
18543
|
const setAuthHeaders = (projectKey) => {
|
|
18517
18544
|
var _a;
|
|
@@ -18528,14 +18555,6 @@ function initializeAxios({ projectKey, baseURL, }) {
|
|
|
18528
18555
|
setAuthHeaders(projectKey);
|
|
18529
18556
|
}
|
|
18530
18557
|
|
|
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
18558
|
const create = (ciBuildId, payload) => axios.post(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities`, {
|
|
18540
18559
|
test_entity: payload,
|
|
18541
18560
|
});
|
|
@@ -18560,7 +18579,7 @@ class MyReporter {
|
|
|
18560
18579
|
}));
|
|
18561
18580
|
}
|
|
18562
18581
|
catch (error) {
|
|
18563
|
-
consoleLogFormatted.error(error);
|
|
18582
|
+
consoleLogFormatted.error(error.message);
|
|
18564
18583
|
throw new Error(ERRORS.onBegin.failedToInitializeRun);
|
|
18565
18584
|
}
|
|
18566
18585
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
@@ -18569,11 +18588,14 @@ class MyReporter {
|
|
|
18569
18588
|
consoleLogFormatted.dim(MESSAGES.onBegin.totalShards(shard.total));
|
|
18570
18589
|
consoleLogFormatted.dim(MESSAGES.onBegin.currentShard(shard.current));
|
|
18571
18590
|
}
|
|
18591
|
+
await sendHeartBeatSignal(this.ciBuildId);
|
|
18592
|
+
setInterval(async () => await sendHeartBeatSignal(this.ciBuildId), 60000);
|
|
18572
18593
|
this.attempts = attempts;
|
|
18573
18594
|
this.config = config;
|
|
18574
18595
|
this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
|
|
18575
18596
|
};
|
|
18576
18597
|
this.onTestBegin = async ({ id, title }, { retry }) => {
|
|
18598
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
|
|
18577
18599
|
try {
|
|
18578
18600
|
const formData = new FormData();
|
|
18579
18601
|
formData.append("attempt[status]", "running");
|
|
@@ -18581,8 +18603,8 @@ class MyReporter {
|
|
|
18581
18603
|
(await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData));
|
|
18582
18604
|
}
|
|
18583
18605
|
catch (error) {
|
|
18606
|
+
consoleLogFormatted.error(error.message);
|
|
18584
18607
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18585
|
-
console.log(error);
|
|
18586
18608
|
}
|
|
18587
18609
|
};
|
|
18588
18610
|
this.onTestEnd = async ({ id, title }, { status, duration, errors, retry, attachments }) => {
|
|
@@ -18607,10 +18629,11 @@ class MyReporter {
|
|
|
18607
18629
|
retry === 0
|
|
18608
18630
|
? await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData)
|
|
18609
18631
|
: await attemptsApi.create(this.ciBuildId, id, formData);
|
|
18632
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18610
18633
|
}
|
|
18611
18634
|
catch (error) {
|
|
18635
|
+
consoleLogFormatted.error(error.message);
|
|
18612
18636
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18613
|
-
console.log(error);
|
|
18614
18637
|
}
|
|
18615
18638
|
};
|
|
18616
18639
|
this.onEnd = async ({ status, duration }) => {
|
|
@@ -18624,7 +18647,7 @@ class MyReporter {
|
|
|
18624
18647
|
});
|
|
18625
18648
|
}
|
|
18626
18649
|
catch (error) {
|
|
18627
|
-
|
|
18650
|
+
consoleLogFormatted.error(error.message);
|
|
18628
18651
|
throw new Error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18629
18652
|
}
|
|
18630
18653
|
};
|