@allurereport/core 3.0.0-beta.19 → 3.0.0-beta.21

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/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ export type * from "./api.js";
2
2
  export * from "./utils/misc.js";
3
3
  export * from "./utils/crypto.js";
4
4
  export * from "./utils/path.js";
5
- export * from "./utils/stats.js";
6
5
  export * from "./utils/git.js";
7
6
  export * from "./utils/new.js";
8
7
  export * from "./utils/flaky.js";
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from "./utils/misc.js";
2
2
  export * from "./utils/crypto.js";
3
3
  export * from "./utils/path.js";
4
- export * from "./utils/stats.js";
5
4
  export * from "./utils/git.js";
6
5
  export * from "./utils/new.js";
7
6
  export * from "./utils/flaky.js";
package/dist/report.js CHANGED
@@ -139,7 +139,7 @@ export class AllureReport {
139
139
  });
140
140
  });
141
141
  this.dumpState = async () => {
142
- const { testResults, testCases, fixtures, attachments: attachmentsLinks, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = __classPrivateFieldGet(this, _AllureReport_store, "f").dumpState();
142
+ const { testResults, testCases, fixtures, attachments: attachmentsLinks, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResultsByRules = {}, } = __classPrivateFieldGet(this, _AllureReport_store, "f").dumpState();
143
143
  const allAttachments = await __classPrivateFieldGet(this, _AllureReport_store, "f").allAttachments();
144
144
  const dumpArchive = new ZipWriteStream({
145
145
  zlib: { level: 5 },
@@ -197,6 +197,9 @@ export class AllureReport {
197
197
  await addEntry(Buffer.from(JSON.stringify(indexKnownByHistoryId)), {
198
198
  name: AllureStoreDumpFiles.IndexKnownByHistoryId,
199
199
  });
200
+ await addEntry(Buffer.from(JSON.stringify(qualityGateResultsByRules)), {
201
+ name: AllureStoreDumpFiles.QualityGateResultsByRules,
202
+ });
200
203
  for (const attachment of allAttachments) {
201
204
  const content = await __classPrivateFieldGet(this, _AllureReport_store, "f").attachmentContentById(attachment.id);
202
205
  if (!content) {
@@ -239,6 +242,7 @@ export class AllureReport {
239
242
  const indexAttachmentsByFixtureEntry = await dump.entryData(AllureStoreDumpFiles.IndexAttachmentsByFixture);
240
243
  const indexFixturesByTestResultEntry = await dump.entryData(AllureStoreDumpFiles.IndexFixturesByTestResult);
241
244
  const indexKnownByHistoryIdEntry = await dump.entryData(AllureStoreDumpFiles.IndexKnownByHistoryId);
245
+ const qualityGateResultsByRulesEntry = await dump.entryData(AllureStoreDumpFiles.QualityGateResultsByRules);
242
246
  const attachmentsEntries = Object.entries(await dump.entries()).reduce((acc, [entryName, entry]) => {
243
247
  switch (entryName) {
244
248
  case AllureStoreDumpFiles.Attachments:
@@ -256,6 +260,7 @@ export class AllureReport {
256
260
  case AllureStoreDumpFiles.IndexAttachmentsByFixture:
257
261
  case AllureStoreDumpFiles.IndexFixturesByTestResult:
258
262
  case AllureStoreDumpFiles.IndexKnownByHistoryId:
263
+ case AllureStoreDumpFiles.QualityGateResultsByRules:
259
264
  return acc;
260
265
  default:
261
266
  return Object.assign(acc, {
@@ -279,6 +284,7 @@ export class AllureReport {
279
284
  indexAttachmentByFixture: JSON.parse(indexAttachmentsByFixtureEntry.toString("utf8")),
280
285
  indexFixturesByTestResult: JSON.parse(indexFixturesByTestResultEntry.toString("utf8")),
281
286
  indexKnownByHistoryId: JSON.parse(indexKnownByHistoryIdEntry.toString("utf8")),
287
+ qualityGateResultsByRules: JSON.parse(qualityGateResultsByRulesEntry.toString("utf8")),
282
288
  };
283
289
  const stageTempDir = await mkdtemp(join(tmpdir(), basename(stage, ".zip")));
284
290
  const resultsAttachments = {};
@@ -445,6 +451,7 @@ export class AllureReport {
445
451
  reportName: __classPrivateFieldGet(this, _AllureReport_reportName, "f"),
446
452
  state: pluginState,
447
453
  reportFiles: pluginFiles,
454
+ reportUrl: this.reportUrl,
448
455
  ci: __classPrivateFieldGet(this, _AllureReport_ci, "f"),
449
456
  };
450
457
  try {
@@ -1,8 +1,8 @@
1
- import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type RepoData, type ReportVariables, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
1
+ import { type AllureHistory, type AttachmentLink, type DefaultLabelsConfig, type EnvironmentsConfig, type HistoryDataPoint, type HistoryTestResult, type KnownTestFailure, type RepoData, type ReportVariables, type Statistic, type TestCase, type TestEnvGroup, type TestError, type TestFixtureResult, type TestResult } from "@allurereport/core-api";
2
2
  import { type AllureStore, type AllureStoreDump, type ExitCode, type QualityGateValidationResult, type RealtimeEventsDispatcher, type RealtimeSubscriber, type ResultFile, type TestResultFilter } from "@allurereport/plugin-api";
3
3
  import type { RawFixtureResult, RawMetadata, RawTestResult, ReaderContext, ResultsVisitor } from "@allurereport/reader-api";
4
4
  export declare const mapToObject: <K extends string | number | symbol, T = any>(map: Map<K, T>) => Record<K, T>;
5
- export declare const mergeMapWithRecord: <K extends string | number | symbol, T = any>(map: Map<K, T>, record: Record<K, T>) => Map<K, T>;
5
+ export declare const updateMapWithRecord: <K extends string | number | symbol, T = any>(map: Map<K, T>, record: Record<K, T>) => Map<K, T>;
6
6
  export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
7
7
  #private;
8
8
  readonly indexTestResultByTestCase: Map<string, TestResult[]>;
@@ -64,7 +64,7 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
64
64
  [x: string]: TestResult[];
65
65
  _: TestResult[];
66
66
  }>;
67
- testsStatistic(filter?: TestResultFilter): Promise<import("@allurereport/core-api").Statistic>;
67
+ testsStatistic(filter?: TestResultFilter): Promise<Statistic>;
68
68
  allEnvironments(): Promise<string[]>;
69
69
  testResultsByEnvironment(env: string, options?: {
70
70
  includeHidden: boolean;
@@ -15,7 +15,6 @@ import { md5, } from "@allurereport/plugin-api";
15
15
  import { isFlaky } from "../utils/flaky.js";
16
16
  import { getGitBranch, getGitRepoName } from "../utils/git.js";
17
17
  import { getStatusTransition } from "../utils/new.js";
18
- import { getTestResultsStats } from "../utils/stats.js";
19
18
  import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
20
19
  const index = (indexMap, key, ...items) => {
21
20
  if (key) {
@@ -58,28 +57,9 @@ export const mapToObject = (map) => {
58
57
  });
59
58
  return result;
60
59
  };
61
- export const mergeMapWithRecord = (map, record) => {
60
+ export const updateMapWithRecord = (map, record) => {
62
61
  Object.entries(record).forEach(([key, value]) => {
63
- const existingValue = map.get(key);
64
- if (existingValue !== undefined) {
65
- if (Array.isArray(existingValue) && Array.isArray(value)) {
66
- map.set(key, [...existingValue, ...value]);
67
- }
68
- else if (typeof existingValue === "object" &&
69
- existingValue !== null &&
70
- typeof value === "object" &&
71
- value !== null &&
72
- !Array.isArray(existingValue) &&
73
- !Array.isArray(value)) {
74
- map.set(key, { ...existingValue, ...value });
75
- }
76
- else {
77
- map.set(key, value);
78
- }
79
- }
80
- else {
81
- map.set(key, value);
82
- }
62
+ map.set(key, value);
83
63
  });
84
64
  return map;
85
65
  };
@@ -281,15 +261,28 @@ export class DefaultAllureStore {
281
261
  }
282
262
  async allTestResults(options = { includeHidden: false }) {
283
263
  const { includeHidden } = options;
284
- const result = Array.from(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").values());
285
- return includeHidden ? result : result.filter((tr) => !tr.hidden);
264
+ const result = [];
265
+ for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
266
+ if (!includeHidden && tr.hidden) {
267
+ continue;
268
+ }
269
+ result.push(tr);
270
+ }
271
+ return result;
286
272
  }
287
273
  async allAttachments(options = {}) {
288
274
  const { includeMissed = false, includeUnused = false } = options;
289
- const attachments = Array.from(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f").values());
290
- return attachments
291
- .filter((link) => (!includeMissed ? !link.missed : true))
292
- .filter((link) => (!includeUnused ? link.used : true));
275
+ const filteredAttachments = [];
276
+ for (const [, attachment] of __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f")) {
277
+ if (!includeMissed && attachment.missed) {
278
+ continue;
279
+ }
280
+ if (!includeUnused && !attachment.used) {
281
+ continue;
282
+ }
283
+ filteredAttachments.push(attachment);
284
+ }
285
+ return filteredAttachments;
293
286
  }
294
287
  async allMetadata() {
295
288
  const result = {};
@@ -306,14 +299,21 @@ export class DefaultAllureStore {
306
299
  return __classPrivateFieldGet(this, _DefaultAllureStore_known, "f");
307
300
  }
308
301
  async allNewTestResults() {
309
- const allTrs = await this.allTestResults();
302
+ const newTrs = [];
310
303
  const allHistoryDps = await this.allHistoryDataPoints();
311
- return allTrs.filter((tr) => {
304
+ for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
305
+ if (tr.hidden) {
306
+ continue;
307
+ }
312
308
  if (!tr.historyId) {
313
- return true;
309
+ newTrs.push(tr);
310
+ continue;
314
311
  }
315
- return !allHistoryDps.some((dp) => dp.testResults[tr.historyId]);
316
- });
312
+ if (!allHistoryDps.some((dp) => dp.testResults[tr.historyId])) {
313
+ newTrs.push(tr);
314
+ }
315
+ }
316
+ return newTrs;
317
317
  }
318
318
  async testCaseById(tcId) {
319
319
  return __classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f").get(tcId);
@@ -359,8 +359,16 @@ export class DefaultAllureStore {
359
359
  return this.indexFixturesByTestResult.get(trId) ?? [];
360
360
  }
361
361
  async failedTestResults() {
362
- const allTestResults = await this.allTestResults();
363
- return allTestResults.filter(({ status }) => status === "failed" || status === "broken");
362
+ const failedTrs = [];
363
+ for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
364
+ if (tr.hidden) {
365
+ continue;
366
+ }
367
+ if (tr.status === "failed" || tr.status === "broken") {
368
+ failedTrs.push(tr);
369
+ }
370
+ }
371
+ return failedTrs;
364
372
  }
365
373
  async unknownFailedTestResults() {
366
374
  const failedTestResults = await this.failedTestResults();
@@ -374,12 +382,14 @@ export class DefaultAllureStore {
374
382
  const results = {
375
383
  _: [],
376
384
  };
377
- const all = await this.allTestResults();
378
- all.forEach((test) => {
385
+ for (const [, test] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
386
+ if (test.hidden) {
387
+ continue;
388
+ }
379
389
  const targetLabels = (test.labels ?? []).filter((label) => label.name === labelName);
380
390
  if (targetLabels.length === 0) {
381
391
  results._.push(test);
382
- return;
392
+ continue;
383
393
  }
384
394
  targetLabels.forEach((label) => {
385
395
  if (!results[label.value]) {
@@ -387,42 +397,65 @@ export class DefaultAllureStore {
387
397
  }
388
398
  results[label.value].push(test);
389
399
  });
390
- });
400
+ }
391
401
  return results;
392
402
  }
393
403
  async testsStatistic(filter) {
394
- const all = await this.allTestResults();
395
- const allWithStats = await Promise.all(all.map(async (tr) => {
404
+ const statistic = { total: 0 };
405
+ for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
406
+ if (tr.hidden) {
407
+ continue;
408
+ }
409
+ if (filter && !filter(tr)) {
410
+ continue;
411
+ }
412
+ statistic.total++;
396
413
  const retries = await this.retriesByTr(tr);
397
- return {
398
- ...tr,
399
- retries,
400
- };
401
- }));
402
- return getTestResultsStats(allWithStats, filter);
414
+ if (retries.length > 0) {
415
+ statistic.retries = (statistic.retries ?? 0) + 1;
416
+ }
417
+ if (tr.flaky) {
418
+ statistic.flaky = (statistic.flaky ?? 0) + 1;
419
+ }
420
+ if (tr.transition === "new") {
421
+ statistic.new = (statistic.new ?? 0) + 1;
422
+ }
423
+ if (!statistic[tr.status]) {
424
+ statistic[tr.status] = 0;
425
+ }
426
+ statistic[tr.status]++;
427
+ }
428
+ return statistic;
403
429
  }
404
430
  async allEnvironments() {
405
431
  return __classPrivateFieldGet(this, _DefaultAllureStore_environments, "f");
406
432
  }
407
433
  async testResultsByEnvironment(env, options = { includeHidden: false }) {
408
- const allTrs = await this.allTestResults(options);
409
- return allTrs.filter((tr) => tr.environment === env);
434
+ const trs = [];
435
+ for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
436
+ if (!options.includeHidden && tr.hidden) {
437
+ continue;
438
+ }
439
+ if (tr.environment === env) {
440
+ trs.push(tr);
441
+ }
442
+ }
443
+ return trs;
410
444
  }
411
445
  async allTestEnvGroups() {
412
- const allTr = await this.allTestResults({ includeHidden: true });
413
- const trByTestCaseId = allTr.reduce((acc, tr) => {
446
+ const trByTestCaseId = {};
447
+ for (const [, tr] of __classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f")) {
414
448
  const testCaseId = tr?.testCase?.id;
415
449
  if (!testCaseId) {
416
- return acc;
450
+ continue;
417
451
  }
418
- if (acc[testCaseId]) {
419
- acc[testCaseId].push(tr);
452
+ if (trByTestCaseId[testCaseId]) {
453
+ trByTestCaseId[testCaseId].push(tr);
420
454
  }
421
455
  else {
422
- acc[testCaseId] = [tr];
456
+ trByTestCaseId[testCaseId] = [tr];
423
457
  }
424
- return acc;
425
- }, {});
458
+ }
426
459
  return Object.entries(trByTestCaseId).reduce((acc, [testCaseId, trs]) => {
427
460
  if (trs.length === 0) {
428
461
  return acc;
@@ -469,6 +502,7 @@ export class DefaultAllureStore {
469
502
  indexAttachmentByFixture: {},
470
503
  indexFixturesByTestResult: {},
471
504
  indexKnownByHistoryId: {},
505
+ qualityGateResultsByRules: __classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f"),
472
506
  };
473
507
  this.indexLatestEnvTestResultByHistoryId.forEach((envMap) => {
474
508
  envMap.forEach((tr, historyId) => {
@@ -496,12 +530,12 @@ export class DefaultAllureStore {
496
530
  return storeDump;
497
531
  }
498
532
  async restoreState(stateDump, attachmentsContents = {}) {
499
- const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, } = stateDump;
500
- mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f"), testResults);
501
- mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
502
- mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
503
- mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
504
- mergeMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f"), attachmentsContents);
533
+ const { testResults, attachments, testCases, fixtures, reportVariables, environments, globalAttachments = [], globalErrors = [], indexAttachmentByTestResult = {}, indexTestResultByHistoryId = {}, indexTestResultByTestCase = {}, indexLatestEnvTestResultByHistoryId = {}, indexAttachmentByFixture = {}, indexFixturesByTestResult = {}, indexKnownByHistoryId = {}, qualityGateResultsByRules = {}, } = stateDump;
534
+ updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f"), testResults);
535
+ updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"), attachments);
536
+ updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_testCases, "f"), testCases);
537
+ updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_fixtures, "f"), fixtures);
538
+ updateMapWithRecord(__classPrivateFieldGet(this, _DefaultAllureStore_attachmentContents, "f"), attachmentsContents);
505
539
  __classPrivateFieldGet(this, _DefaultAllureStore_instances, "m", _DefaultAllureStore_addEnvironments).call(this, environments);
506
540
  __classPrivateFieldGet(this, _DefaultAllureStore_globalAttachments, "f").push(...globalAttachments);
507
541
  __classPrivateFieldGet(this, _DefaultAllureStore_globalErrors, "f").push(...globalErrors);
@@ -581,6 +615,7 @@ export class DefaultAllureStore {
581
615
  }
582
616
  hidePreviousAttempt(this.indexLatestEnvTestResultByHistoryId, tr);
583
617
  });
618
+ Object.assign(__classPrivateFieldGet(this, _DefaultAllureStore_qualityGateResultsByRules, "f"), qualityGateResultsByRules);
584
619
  }
585
620
  }
586
621
  _DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_environment = new WeakMap(), _DefaultAllureStore_environmentsConfig = new WeakMap(), _DefaultAllureStore_reportVariables = new WeakMap(), _DefaultAllureStore_realtimeDispatcher = new WeakMap(), _DefaultAllureStore_realtimeSubscriber = new WeakMap(), _DefaultAllureStore_globalAttachments = new WeakMap(), _DefaultAllureStore_globalErrors = new WeakMap(), _DefaultAllureStore_globalExitCode = new WeakMap(), _DefaultAllureStore_qualityGateResultsByRules = new WeakMap(), _DefaultAllureStore_historyPoints = new WeakMap(), _DefaultAllureStore_repoData = new WeakMap(), _DefaultAllureStore_environments = new WeakMap(), _DefaultAllureStore_instances = new WeakSet(), _DefaultAllureStore_addEnvironments = function _DefaultAllureStore_addEnvironments(envs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/core",
3
- "version": "3.0.0-beta.19",
3
+ "version": "3.0.0-beta.21",
4
4
  "description": "Collection of generic Allure utilities used across the entire project",
5
5
  "keywords": [
6
6
  "allure"
@@ -25,22 +25,23 @@
25
25
  "test": "vitest run"
26
26
  },
27
27
  "dependencies": {
28
- "@allurereport/ci": "3.0.0-beta.19",
29
- "@allurereport/core-api": "3.0.0-beta.19",
30
- "@allurereport/plugin-allure2": "3.0.0-beta.19",
31
- "@allurereport/plugin-api": "3.0.0-beta.19",
32
- "@allurereport/plugin-awesome": "3.0.0-beta.19",
33
- "@allurereport/plugin-classic": "3.0.0-beta.19",
34
- "@allurereport/plugin-csv": "3.0.0-beta.19",
35
- "@allurereport/plugin-dashboard": "3.0.0-beta.19",
36
- "@allurereport/plugin-log": "3.0.0-beta.19",
37
- "@allurereport/plugin-progress": "3.0.0-beta.19",
38
- "@allurereport/plugin-slack": "3.0.0-beta.19",
39
- "@allurereport/plugin-testplan": "3.0.0-beta.19",
40
- "@allurereport/reader": "3.0.0-beta.19",
41
- "@allurereport/reader-api": "3.0.0-beta.19",
42
- "@allurereport/service": "3.0.0-beta.19",
43
- "@allurereport/summary": "3.0.0-beta.19",
28
+ "@allurereport/ci": "3.0.0-beta.21",
29
+ "@allurereport/core-api": "3.0.0-beta.21",
30
+ "@allurereport/plugin-allure2": "3.0.0-beta.21",
31
+ "@allurereport/plugin-api": "3.0.0-beta.21",
32
+ "@allurereport/plugin-awesome": "3.0.0-beta.21",
33
+ "@allurereport/plugin-classic": "3.0.0-beta.21",
34
+ "@allurereport/plugin-csv": "3.0.0-beta.21",
35
+ "@allurereport/plugin-dashboard": "3.0.0-beta.21",
36
+ "@allurereport/plugin-jira": "3.0.0-beta.21",
37
+ "@allurereport/plugin-log": "3.0.0-beta.21",
38
+ "@allurereport/plugin-progress": "3.0.0-beta.21",
39
+ "@allurereport/plugin-slack": "3.0.0-beta.21",
40
+ "@allurereport/plugin-testplan": "3.0.0-beta.21",
41
+ "@allurereport/reader": "3.0.0-beta.21",
42
+ "@allurereport/reader-api": "3.0.0-beta.21",
43
+ "@allurereport/service": "3.0.0-beta.21",
44
+ "@allurereport/summary": "3.0.0-beta.21",
44
45
  "handlebars": "^4.7.8",
45
46
  "markdown-it": "^14.1.0",
46
47
  "node-stream-zip": "^1.15.0",
@@ -1,2 +0,0 @@
1
- import type { Statistic, TestResult } from "@allurereport/core-api";
2
- export declare const getTestResultsStats: (trs: TestResult[], filter?: (tr: TestResult) => boolean) => Statistic;
@@ -1,22 +0,0 @@
1
- export const getTestResultsStats = (trs, filter = () => true) => {
2
- const trsToProcess = trs.filter(filter);
3
- return trsToProcess.reduce((acc, tr) => {
4
- if (filter && !filter(tr)) {
5
- return acc;
6
- }
7
- if (tr.retries && tr.retries?.length > 0) {
8
- acc.retries = (acc.retries ?? 0) + 1;
9
- }
10
- if (tr.flaky) {
11
- acc.flaky = (acc.flaky ?? 0) + 1;
12
- }
13
- if (tr.transition === "new") {
14
- acc.new = (acc.new ?? 0) + 1;
15
- }
16
- if (!acc[tr.status]) {
17
- acc[tr.status] = 0;
18
- }
19
- acc[tr.status]++;
20
- return acc;
21
- }, { total: trsToProcess.length });
22
- };