@bigbinary/neeto-playwright-reporter 1.3.21 → 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.d.ts CHANGED
@@ -21,9 +21,10 @@ declare class MyReporter implements Reporter {
21
21
  hasRunStarted: boolean;
22
22
  testAttemptIds: string[];
23
23
  heartbeatInterval: NodeJS.Timeout | null;
24
+ rootDir: string;
24
25
  constructor(options: ReporterOptionParams);
25
26
  onBegin: (config: FullConfig, rootSuite: Suite) => Promise<void>;
26
- onTestBegin: ({ id, title, repeatEachIndex }: TestCase, { retry }: TestResult) => Promise<void>;
27
+ onTestBegin: (test: TestCase, { retry }: TestResult) => Promise<void>;
27
28
  onTestEnd: (testCase: TestCase, { status, duration, errors, error, retry, attachments }: TestResult) => Promise<void>;
28
29
  onEnd: ({ status, duration }: FullResult) => Promise<void>;
29
30
  }
package/index.js CHANGED
@@ -11,6 +11,7 @@ import require$$0$2 from 'os';
11
11
  import zlib from 'zlib';
12
12
  import EventEmitter from 'events';
13
13
  import crypto from 'crypto';
14
+ import { uniq } from 'ramda';
14
15
  import childProcess from 'child_process';
15
16
 
16
17
  function bind(fn, thisArg) {
@@ -18496,6 +18497,14 @@ const createShardObject = ({ currentShard = 0, status = "running", duration = nu
18496
18497
  [currentShard]: { status, duration },
18497
18498
  });
18498
18499
  const waitUntilTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
18500
+ const convertToSha1 = (text) => crypto.createHash("sha1").update(text).digest("hex").slice(0, 20);
18501
+ const generateHistoryId = (projectId, specName, describeTitles, testTitle) => {
18502
+ const titles = [...describeTitles, testTitle];
18503
+ const targetString = `[project=${projectId}]${specName}\x1e${titles.join("\x1e")}`;
18504
+ const targetStringSha = convertToSha1(targetString);
18505
+ const pathNameSha = convertToSha1(specName);
18506
+ return `${pathNameSha}-${targetStringSha}`;
18507
+ };
18499
18508
 
18500
18509
  const LOG_LEVEL_FORMATTERS = {
18501
18510
  bold: "\x1b[1m",
@@ -18585,15 +18594,17 @@ const getCurrentAuthor = () => executeCommandLine({
18585
18594
  command: "git show -s --format='%an' HEAD",
18586
18595
  messageOnError: ERRORS.onBegin.failedToGetBranch,
18587
18596
  });
18588
- const getInitializerData = ({ rootDir }, rootSuite) => rootSuite.allTests().map(test => {
18597
+ const getTestData = (test, rootDir) => {
18589
18598
  var _a;
18590
- const { title, parent, id: history_id, location: { file }, } = test;
18599
+ const { title, parent, location: { file }, } = test;
18591
18600
  const titlePath = test.titlePath();
18592
18601
  const project = (_a = parent.project()) === null || _a === void 0 ? void 0 : _a.name;
18593
18602
  const spec = file.replace(`${rootDir}/`, "");
18594
18603
  const describe = getDescribePath({ titlePath, title, spec, project });
18595
- return { title, describe, project, spec, history_id };
18596
- });
18604
+ const historyId = generateHistoryId(project !== null && project !== void 0 ? project : "", spec, describe, title);
18605
+ return { title, describe, project, spec, history_id: historyId };
18606
+ };
18607
+ const getInitializerData = ({ rootDir }, rootSuite) => uniq(rootSuite.allTests().map(test => getTestData(test, rootDir)));
18597
18608
  const sendHeartBeatSignal = async (ciBuildId) => {
18598
18609
  try {
18599
18610
  await runsApi.heartbeat(ciBuildId);
@@ -18634,12 +18645,13 @@ const testEntitiesApi = { create };
18634
18645
  class MyReporter {
18635
18646
  constructor(options) {
18636
18647
  this.onBegin = async (config, rootSuite) => {
18637
- var _a, _b, _c;
18648
+ var _a, _b, _c, _d;
18638
18649
  const shard = config.shard;
18639
18650
  this.config = config;
18640
18651
  this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
18641
18652
  let attempts = {};
18642
18653
  this.totalTestCount = rootSuite.allTests().length;
18654
+ this.rootDir = config.rootDir;
18643
18655
  try {
18644
18656
  const runDetails = {
18645
18657
  commit_id: getCurrentCommitSha(),
@@ -18659,15 +18671,16 @@ class MyReporter {
18659
18671
  }
18660
18672
  ({ data: attempts } = await testEntitiesApi.create(this.ciBuildId, {
18661
18673
  test_entities: getInitializerData(config, rootSuite),
18674
+ shard: (_a = this.currentShard) !== null && _a !== void 0 ? _a : 0,
18662
18675
  }));
18663
18676
  }
18664
18677
  catch (error) {
18665
18678
  const axiosError = error;
18666
- const data = (_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.data;
18667
- consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : axiosError.message);
18679
+ const data = (_b = axiosError.response) === null || _b === void 0 ? void 0 : _b.data;
18680
+ consoleLogFormatted.error((_c = data === null || data === void 0 ? void 0 : data.error) !== null && _c !== void 0 ? _c : axiosError.message);
18668
18681
  consoleLogFormatted.error(ERRORS.onBegin.failedToInitializeRun);
18669
18682
  process.kill(process.pid, "SIGKILL");
18670
- ((_c = axiosError.response) === null || _c === void 0 ? void 0 : _c.status) === 422 && process.exit(1);
18683
+ ((_d = axiosError.response) === null || _d === void 0 ? void 0 : _d.status) === 422 && process.exit(1);
18671
18684
  }
18672
18685
  consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
18673
18686
  consoleLogFormatted.dim(MESSAGES.onBegin.ciBuildId(this.ciBuildId));
@@ -18679,8 +18692,10 @@ class MyReporter {
18679
18692
  this.heartbeatInterval = setInterval(async () => await sendHeartBeatSignal(this.ciBuildId), 45000);
18680
18693
  this.attempts = attempts;
18681
18694
  };
18682
- this.onTestBegin = async ({ id, title, repeatEachIndex }, { retry }) => {
18695
+ this.onTestBegin = async (test, { retry }) => {
18683
18696
  var _a, _b;
18697
+ const { title, repeatEachIndex } = test;
18698
+ const { history_id: id } = getTestData(test, this.rootDir);
18684
18699
  this.retryAttemptStartedAt = new Date();
18685
18700
  this.unreportedAttemptCount++;
18686
18701
  consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
@@ -18717,7 +18732,8 @@ class MyReporter {
18717
18732
  var _a;
18718
18733
  const completedAt = new Date();
18719
18734
  const errorLocation = error === null || error === void 0 ? void 0 : error.location;
18720
- const { id, title, repeatEachIndex } = testCase;
18735
+ const { title, repeatEachIndex } = testCase;
18736
+ const { history_id: id } = getTestData(testCase, this.rootDir);
18721
18737
  const testOutcome = testCase.outcome();
18722
18738
  const outcome = {
18723
18739
  shard: (_a = this.currentShard) !== null && _a !== void 0 ? _a : 0,
@@ -18806,6 +18822,7 @@ class MyReporter {
18806
18822
  this.hasRunStarted = false;
18807
18823
  this.testAttemptIds = [];
18808
18824
  this.heartbeatInterval = null;
18825
+ this.rootDir = "";
18809
18826
  process.on("unhandledRejection", async (error) => {
18810
18827
  var _a, _b, _c;
18811
18828
  const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;