Skip to content

Commit

Permalink
fix: export TestResult and Suite types (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr authored Sep 6, 2023
1 parent bb25649 commit 0d24037
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 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
66 changes: 54 additions & 12 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 {
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;
Expand All @@ -70,15 +110,17 @@ export interface CommandHistory {
}

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

export interface TestResultWithRetries extends TestResult {
Expand Down

0 comments on commit 0d24037

Please sign in to comment.