@bigbinary/neeto-playwright-reporter 1.3.21 → 1.3.23
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 +28 -10
- package/index.cjs.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +28 -10
- package/index.js.map +1 -1
- package/package.json +2 -1
package/index.cjs.js
CHANGED
|
@@ -13,6 +13,7 @@ var require$$0$2 = require('os');
|
|
|
13
13
|
var zlib = require('zlib');
|
|
14
14
|
var EventEmitter = require('events');
|
|
15
15
|
var crypto = require('crypto');
|
|
16
|
+
var ramda = require('ramda');
|
|
16
17
|
var childProcess = require('child_process');
|
|
17
18
|
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -18515,6 +18516,14 @@ const createShardObject = ({ currentShard = 0, status = "running", duration = nu
|
|
|
18515
18516
|
[currentShard]: { status, duration },
|
|
18516
18517
|
});
|
|
18517
18518
|
const waitUntilTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
|
|
18519
|
+
const convertToSha1 = (text) => crypto__default["default"].createHash("sha1").update(text).digest("hex").slice(0, 20);
|
|
18520
|
+
const generateHistoryId = (projectId, specName, describeTitles, testTitle) => {
|
|
18521
|
+
const titles = [...describeTitles, testTitle];
|
|
18522
|
+
const targetString = `[project=${projectId}]${specName}\x1e${titles.join("\x1e")}`;
|
|
18523
|
+
const targetStringSha = convertToSha1(targetString);
|
|
18524
|
+
const pathNameSha = convertToSha1(specName);
|
|
18525
|
+
return `${pathNameSha}-${targetStringSha}`;
|
|
18526
|
+
};
|
|
18518
18527
|
|
|
18519
18528
|
const LOG_LEVEL_FORMATTERS = {
|
|
18520
18529
|
bold: "\x1b[1m",
|
|
@@ -18604,15 +18613,17 @@ const getCurrentAuthor = () => executeCommandLine({
|
|
|
18604
18613
|
command: "git show -s --format='%an' HEAD",
|
|
18605
18614
|
messageOnError: ERRORS.onBegin.failedToGetBranch,
|
|
18606
18615
|
});
|
|
18607
|
-
const
|
|
18616
|
+
const getTestData = (test, rootDir) => {
|
|
18608
18617
|
var _a;
|
|
18609
|
-
const { title, parent,
|
|
18618
|
+
const { title, parent, location: { file }, } = test;
|
|
18610
18619
|
const titlePath = test.titlePath();
|
|
18611
18620
|
const project = (_a = parent.project()) === null || _a === void 0 ? void 0 : _a.name;
|
|
18612
18621
|
const spec = file.replace(`${rootDir}/`, "");
|
|
18613
18622
|
const describe = getDescribePath({ titlePath, title, spec, project });
|
|
18614
|
-
|
|
18615
|
-
}
|
|
18623
|
+
const historyId = generateHistoryId(project !== null && project !== void 0 ? project : "", spec, describe, title);
|
|
18624
|
+
return { title, describe, project, spec, history_id: historyId };
|
|
18625
|
+
};
|
|
18626
|
+
const getInitializerData = ({ rootDir }, rootSuite) => ramda.uniq(rootSuite.allTests().map(test => getTestData(test, rootDir)));
|
|
18616
18627
|
const sendHeartBeatSignal = async (ciBuildId) => {
|
|
18617
18628
|
try {
|
|
18618
18629
|
await runsApi.heartbeat(ciBuildId);
|
|
@@ -18653,12 +18664,13 @@ const testEntitiesApi = { create };
|
|
|
18653
18664
|
class MyReporter {
|
|
18654
18665
|
constructor(options) {
|
|
18655
18666
|
this.onBegin = async (config, rootSuite) => {
|
|
18656
|
-
var _a, _b, _c;
|
|
18667
|
+
var _a, _b, _c, _d;
|
|
18657
18668
|
const shard = config.shard;
|
|
18658
18669
|
this.config = config;
|
|
18659
18670
|
this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
|
|
18660
18671
|
let attempts = {};
|
|
18661
18672
|
this.totalTestCount = rootSuite.allTests().length;
|
|
18673
|
+
this.rootDir = config.rootDir;
|
|
18662
18674
|
try {
|
|
18663
18675
|
const runDetails = {
|
|
18664
18676
|
commit_id: getCurrentCommitSha(),
|
|
@@ -18678,15 +18690,16 @@ class MyReporter {
|
|
|
18678
18690
|
}
|
|
18679
18691
|
({ data: attempts } = await testEntitiesApi.create(this.ciBuildId, {
|
|
18680
18692
|
test_entities: getInitializerData(config, rootSuite),
|
|
18693
|
+
shard: (_a = this.currentShard) !== null && _a !== void 0 ? _a : 0,
|
|
18681
18694
|
}));
|
|
18682
18695
|
}
|
|
18683
18696
|
catch (error) {
|
|
18684
18697
|
const axiosError = error;
|
|
18685
|
-
const data = (
|
|
18686
|
-
consoleLogFormatted.error((
|
|
18698
|
+
const data = (_b = axiosError.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
18699
|
+
consoleLogFormatted.error((_c = data === null || data === void 0 ? void 0 : data.error) !== null && _c !== void 0 ? _c : axiosError.message);
|
|
18687
18700
|
consoleLogFormatted.error(ERRORS.onBegin.failedToInitializeRun);
|
|
18688
18701
|
process.kill(process.pid, "SIGKILL");
|
|
18689
|
-
((
|
|
18702
|
+
((_d = axiosError.response) === null || _d === void 0 ? void 0 : _d.status) === 422 && process.exit(1);
|
|
18690
18703
|
}
|
|
18691
18704
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
18692
18705
|
consoleLogFormatted.dim(MESSAGES.onBegin.ciBuildId(this.ciBuildId));
|
|
@@ -18698,8 +18711,10 @@ class MyReporter {
|
|
|
18698
18711
|
this.heartbeatInterval = setInterval(async () => await sendHeartBeatSignal(this.ciBuildId), 45000);
|
|
18699
18712
|
this.attempts = attempts;
|
|
18700
18713
|
};
|
|
18701
|
-
this.onTestBegin = async (
|
|
18714
|
+
this.onTestBegin = async (test, { retry }) => {
|
|
18702
18715
|
var _a, _b;
|
|
18716
|
+
const { title, repeatEachIndex } = test;
|
|
18717
|
+
const { history_id: id } = getTestData(test, this.rootDir);
|
|
18703
18718
|
this.retryAttemptStartedAt = new Date();
|
|
18704
18719
|
this.unreportedAttemptCount++;
|
|
18705
18720
|
consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
|
|
@@ -18710,6 +18725,7 @@ class MyReporter {
|
|
|
18710
18725
|
status: "running",
|
|
18711
18726
|
started_at: this.retryAttemptStartedAt.toString(),
|
|
18712
18727
|
shard: this.currentShard,
|
|
18728
|
+
repeatEachIndex,
|
|
18713
18729
|
};
|
|
18714
18730
|
if (retry === 0 && repeatEachIndex === 0) {
|
|
18715
18731
|
await attemptsApi.update(this.ciBuildId, id, this.attempts[id]["0-0"], attemptsPayload);
|
|
@@ -18736,7 +18752,8 @@ class MyReporter {
|
|
|
18736
18752
|
var _a;
|
|
18737
18753
|
const completedAt = new Date();
|
|
18738
18754
|
const errorLocation = error === null || error === void 0 ? void 0 : error.location;
|
|
18739
|
-
const {
|
|
18755
|
+
const { title, repeatEachIndex } = testCase;
|
|
18756
|
+
const { history_id: id } = getTestData(testCase, this.rootDir);
|
|
18740
18757
|
const testOutcome = testCase.outcome();
|
|
18741
18758
|
const outcome = {
|
|
18742
18759
|
shard: (_a = this.currentShard) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -18825,6 +18842,7 @@ class MyReporter {
|
|
|
18825
18842
|
this.hasRunStarted = false;
|
|
18826
18843
|
this.testAttemptIds = [];
|
|
18827
18844
|
this.heartbeatInterval = null;
|
|
18845
|
+
this.rootDir = "";
|
|
18828
18846
|
process.on("unhandledRejection", async (error) => {
|
|
18829
18847
|
var _a, _b, _c;
|
|
18830
18848
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|