diff --git a/src/index.ts b/src/index.ts index 06c6bb55b..4fe588c5a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ import "expect-webdriverio"; import { GlobalHelper } from "./types"; export { Hermione as default } from "./hermione"; -export type { WdioBrowser } from "./types"; +export type { WdioBrowser, TestResult, Suite } from "./types"; export type { Config } from "./config"; export type { ConfigInput } from "./config/types"; diff --git a/src/types/index.ts b/src/types/index.ts index 7f0203af0..aa4e2f1bc 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -12,6 +12,7 @@ import { SkipController } from "../test-reader/controllers/skip-controller"; import { BrowserVersionController } from "../test-reader/controllers/browser-version-controller"; import { WorkerProcess } from "../utils/worker-process"; import { BaseHermione } from "../base-hermione"; +import { CoordBounds, LooksSameOptions } from "looks-same"; export { Suite as RunnerSuite, Test as RunnerTest } from "mocha"; @@ -31,27 +32,66 @@ export interface BrowserInfo { export type AsyncSessionEventCallback = (browser: Browser, browserInfo: BrowserInfo) => Promise | void; -export interface TestError extends Error { - screenshot?: { - base64: string; - }; -} - export interface ImageSize { width: number; height: number; } +export interface ImageBase64 { + base64: string; + size: ImageSize; +} + +export interface ErrorDetails { + title: string; + data?: unknown; + filePath: string; +} + +export interface TestError extends Error { + screenshot?: ImageBase64; + details: ErrorDetails; +} + export interface ImageInfo { path: string; size: ImageSize; } -export interface AssertViewResultsSuccess { +export interface AssertViewResultSuccess { + refImg: ImageInfo; + stateName: string; +} + +export interface DiffOptions extends LooksSameOptions { + current: string; + reference: string; + diffColor: string; +} + +export interface AssertViewResultDiff { + currImg: ImageInfo; + diffBuffer?: ArrayBuffer; + diffClusters: CoordBounds[]; + diffOpts: DiffOptions; + message: string; + name: "ImageDiffError"; + refImg: ImageInfo; + stack: string; stateName: string; +} + +export interface AssertViewResultNoRefImage { + currImg: ImageInfo; + message: string; + name: "NoRefImageError"; refImg: ImageInfo; + stack: string; + stateName: string; } +export type AssertViewResult = AssertViewResultSuccess | AssertViewResultDiff | AssertViewResultNoRefImage; + export interface CommandHistory { /** Name: command name */ n: string; @@ -70,15 +110,17 @@ export interface CommandHistory { } export interface TestResult extends Test { - startTime: number; + assertViewResults: Array; + description?: string; duration: number; - assertViewResults: Array; - meta: { [name: string]: unknown }; + err?: TestError; hermioneCtx: { - assertViewResults: Array; + assertViewResults: Array; }; history: CommandHistory; - err?: TestError; + meta: { [name: string]: unknown }; + sessionId: string; + startTime: number; } export interface TestResultWithRetries extends TestResult {