Skip to content

Commit

Permalink
fix: export TestResult and Suite types
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Sep 5, 2023
1 parent bb25649 commit 4cb0dfc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
60 changes: 51 additions & 9 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -31,27 +32,66 @@ export interface BrowserInfo {

export type AsyncSessionEventCallback = (browser: Browser, browserInfo: BrowserInfo) => Promise<void> | 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 {
stateName: string;
refImg: ImageInfo;
}

export interface DiffOptions extends LooksSameOptions {
current: string;
reference: string;
diffColor: string;
}

export interface AssertViewResultDiff {
name: "ImageDiffError";
message: string;
stack: string;
stateName: string;
diffOpts: DiffOptions;
currImg: ImageInfo;
refImg: ImageInfo;
diffClusters: CoordBounds[];
diffBuffer?: ArrayBuffer;
}

export interface AssertViewResultNoRefImage {
name: "NoRefImageError";
stateName: string;
message: string;
stack: string;
currImg: ImageInfo;
refImg: ImageInfo;
}

export type AssertViewResult = AssertViewResultSuccess | AssertViewResultDiff | AssertViewResultNoRefImage;

export interface CommandHistory {
/** Name: command name */
n: string;
Expand All @@ -70,15 +110,17 @@ export interface CommandHistory {
}

export interface TestResult extends Test {
description?: string;
startTime: number;
duration: number;
assertViewResults: Array<AssertViewResultsSuccess>;
assertViewResults: Array<AssertViewResult>;
meta: { [name: string]: unknown };
hermioneCtx: {
assertViewResults: Array<AssertViewResultsSuccess>;
assertViewResults: Array<AssertViewResult>;
};
history: CommandHistory;
err?: TestError;
sessionId: string;
}

export interface TestResultWithRetries extends TestResult {
Expand Down

0 comments on commit 4cb0dfc

Please sign in to comment.