@allurereport/core-api
Advanced tools
@@ -20,2 +20,3 @@ import type { Statistic } from "./aggregate.js"; | ||
| export declare const emptyStatistic: () => Statistic; | ||
| export declare const incrementStatistic: (statistic: Statistic, status: TestStatus) => void; | ||
| export declare const incrementStatistic: (statistic: Statistic, status: TestStatus, count?: number) => void; | ||
| export declare const mergeStatistic: (statistic: Statistic, additional: Statistic) => void; |
+10
-3
@@ -13,5 +13,12 @@ export const statusesList = ["failed", "broken", "passed", "skipped", "unknown"]; | ||
| export const emptyStatistic = () => ({ total: 0 }); | ||
| export const incrementStatistic = (statistic, status) => { | ||
| statistic[status] = (statistic[status] ?? 0) + 1; | ||
| statistic.total++; | ||
| export const incrementStatistic = (statistic, status, count = 1) => { | ||
| statistic[status] = (statistic[status] ?? 0) + count; | ||
| statistic.total += count; | ||
| }; | ||
| export const mergeStatistic = (statistic, additional) => { | ||
| statusesList.forEach((status) => { | ||
| if (additional[status]) { | ||
| incrementStatistic(statistic, status, additional[status]); | ||
| } | ||
| }); | ||
| }; |
@@ -1,2 +0,2 @@ | ||
| import type { TestStatus } from "./model.js"; | ||
| import type { TestError, TestStatus } from "./model.js"; | ||
| export interface HistoryTestResult { | ||
@@ -7,4 +7,3 @@ id: string; | ||
| status: TestStatus; | ||
| message?: string; | ||
| trace?: string; | ||
| error?: TestError; | ||
| start?: number; | ||
@@ -11,0 +10,0 @@ stop?: number; |
+2
-1
@@ -1,2 +0,3 @@ | ||
| import type { TestError, TestLink } from "./metadata.js"; | ||
| import type { TestLink } from "./metadata.js"; | ||
| import type { TestError } from "./model.js"; | ||
| export interface KnownTestFailure { | ||
@@ -3,0 +4,0 @@ historyId: string; |
+0
-13
@@ -1,4 +0,1 @@ | ||
| import type { TestStatus } from "./model.js"; | ||
| export interface Location { | ||
| } | ||
| export interface TestLabel { | ||
@@ -20,11 +17,1 @@ name: string; | ||
| } | ||
| export interface TestError { | ||
| id: string; | ||
| message: string; | ||
| trace?: string; | ||
| status?: TestStatus; | ||
| code?: string; | ||
| location?: Location; | ||
| tags: string[]; | ||
| expected?: boolean; | ||
| } |
+9
-6
@@ -10,2 +10,8 @@ import type { TestLabel, TestLink, TestParameter } from "./metadata.js"; | ||
| } | ||
| export interface TestError { | ||
| message?: string; | ||
| trace?: string; | ||
| actual?: string; | ||
| expected?: string; | ||
| } | ||
| export interface TestResult { | ||
@@ -15,4 +21,3 @@ id: string; | ||
| status: TestStatus; | ||
| message?: string; | ||
| trace?: string; | ||
| error?: TestError; | ||
| testCase?: TestCase; | ||
@@ -50,4 +55,3 @@ fullName?: string; | ||
| status: TestStatus; | ||
| message?: string; | ||
| trace?: string; | ||
| error?: TestError; | ||
| start?: number; | ||
@@ -64,4 +68,3 @@ stop?: number; | ||
| status: TestStatus; | ||
| message?: string; | ||
| trace?: string; | ||
| error?: TestError; | ||
| start?: number; | ||
@@ -68,0 +71,0 @@ stop?: number; |
@@ -8,3 +8,5 @@ import type { Statistic } from "../aggregate.js"; | ||
| export declare const nullsLast: <T extends {}>(compare: Comparator<T>) => Comparator<T | undefined>; | ||
| export declare const compareBy: <T extends Record<string, any> = {}, P extends keyof T = keyof T>(property: P, compare: Comparator<Value<T, P>>) => Comparator<T>; | ||
| export declare const nullsFirst: <T extends {}>(compare: Comparator<T>) => Comparator<T | undefined>; | ||
| export declare const nullsDefault: <T extends {}>(compare: Comparator<T>, defaultValue: T) => Comparator<T | undefined>; | ||
| export declare const compareBy: <T extends Record<string, any> = {}, P extends keyof T = keyof T>(property: P, compare: Comparator<Value<T, P>>, defaultValue?: T[P]) => Comparator<T>; | ||
| export declare const andThen: <T>(comparators: Comparator<T>[]) => Comparator<T>; | ||
@@ -11,0 +13,0 @@ export declare const alphabetically: SortFunction<string | undefined>; |
@@ -8,4 +8,13 @@ import { statusesList } from "../constants.js"; | ||
| }; | ||
| export const compareBy = (property, compare) => { | ||
| export const nullsFirst = (compare) => { | ||
| return (a, b) => a === b ? 0 : a === undefined || a === null ? -1 : b === undefined || b === null ? 1 : compare(a, b); | ||
| }; | ||
| export const nullsDefault = (compare, defaultValue) => { | ||
| return (a, b) => compare(a ?? defaultValue, b ?? defaultValue); | ||
| }; | ||
| export const compareBy = (property, compare, defaultValue) => { | ||
| return nullsLast((a, b) => { | ||
| if (defaultValue !== undefined) { | ||
| return compare(a[property] ?? defaultValue, b[property] ?? defaultValue); | ||
| } | ||
| if (property in a && property in b) { | ||
@@ -36,5 +45,5 @@ return compare(a[property], b[property]); | ||
| export const byStatistic = () => { | ||
| const compares = statusesList.map((status) => compareBy(status, reverse(ordinal()))); | ||
| const compares = statusesList.map((status) => compareBy(status, reverse(ordinal()), 0)); | ||
| return nullsLast(andThen(compares)); | ||
| }; | ||
| export const byName = () => nullsLast(compareBy("name", alphabetically())); |
@@ -1,1 +0,1 @@ | ||
| export declare const formatDuration: (duration: number | undefined) => string; | ||
| export declare const formatDuration: (duration?: number) => string; |
+2
-2
| { | ||
| "name": "@allurereport/core-api", | ||
| "version": "3.0.0-beta.7", | ||
| "version": "3.0.0-beta.8", | ||
| "description": "Allure Core API", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
| "@vitest/runner": "^2.1.8", | ||
| "allure-vitest": "^3.0.7", | ||
| "allure-vitest": "^3.0.9", | ||
| "eslint": "^8.57.0", | ||
@@ -38,0 +38,0 @@ "eslint-config-prettier": "^9.1.0", |
16000
5.58%406
2.27%