@bigbinary/neeto-playwright-reporter 1.3.20 → 1.3.22
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 +32 -13
- package/index.cjs.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +32 -13
- 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 }; }
|
|
@@ -18504,7 +18505,7 @@ const MESSAGES = {
|
|
|
18504
18505
|
startingTest: (titlePath) => `Starting ${titlePath}`,
|
|
18505
18506
|
},
|
|
18506
18507
|
onTestEnd: {
|
|
18507
|
-
reportedTest: (title) => `Reported ${title} to NeetoPlaydash`,
|
|
18508
|
+
reportedTest: ({ title, status, id }) => `Reported ${title} with id: ${id} to NeetoPlaydash with status ${status}`,
|
|
18508
18509
|
},
|
|
18509
18510
|
onEnd: {
|
|
18510
18511
|
runReported: "Run completed and reported to NeetoPlaydash 🎉",
|
|
@@ -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));
|
|
@@ -18736,7 +18751,8 @@ class MyReporter {
|
|
|
18736
18751
|
var _a;
|
|
18737
18752
|
const completedAt = new Date();
|
|
18738
18753
|
const errorLocation = error === null || error === void 0 ? void 0 : error.location;
|
|
18739
|
-
const {
|
|
18754
|
+
const { title, repeatEachIndex } = testCase;
|
|
18755
|
+
const { history_id: id } = getTestData(testCase, this.rootDir);
|
|
18740
18756
|
const testOutcome = testCase.outcome();
|
|
18741
18757
|
const outcome = {
|
|
18742
18758
|
shard: (_a = this.currentShard) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -18776,7 +18792,10 @@ class MyReporter {
|
|
|
18776
18792
|
while (!(this.attempts[id][`${retry}-${repeatEachIndex}`] ||
|
|
18777
18793
|
this.testAttemptIds.includes(`${id}-${this.attempts[id][`${retry}-${repeatEachIndex}`]}`)))
|
|
18778
18794
|
await waitUntilTimeout(100);
|
|
18779
|
-
|
|
18795
|
+
const reportToNeetoPlaydash = attemptsApi.update(this.ciBuildId, id, this.attempts[id][`${retry}-${repeatEachIndex}`], testResult);
|
|
18796
|
+
this.testResultCalls.push(reportToNeetoPlaydash);
|
|
18797
|
+
await reportToNeetoPlaydash;
|
|
18798
|
+
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest({ title, status, id }));
|
|
18780
18799
|
}
|
|
18781
18800
|
catch (error) {
|
|
18782
18801
|
consoleLogFormatted.error(error.message);
|
|
@@ -18785,7 +18804,6 @@ class MyReporter {
|
|
|
18785
18804
|
}
|
|
18786
18805
|
finally {
|
|
18787
18806
|
this.unreportedAttemptCount--;
|
|
18788
|
-
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18789
18807
|
}
|
|
18790
18808
|
};
|
|
18791
18809
|
this.onEnd = async ({ status, duration }) => {
|
|
@@ -18823,6 +18841,7 @@ class MyReporter {
|
|
|
18823
18841
|
this.hasRunStarted = false;
|
|
18824
18842
|
this.testAttemptIds = [];
|
|
18825
18843
|
this.heartbeatInterval = null;
|
|
18844
|
+
this.rootDir = "";
|
|
18826
18845
|
process.on("unhandledRejection", async (error) => {
|
|
18827
18846
|
var _a, _b, _c;
|
|
18828
18847
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|