Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export TestResult and Suite types #786

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
shadowusr marked this conversation as resolved.
Show resolved Hide resolved
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
Loading