///
import { CB, DynamicValue, OneOrMoreOf, Maybe, Nullable, ValueOf } from 'vest-utils';
import { TIsolate, IsolateKey } from "vestjs-runtime";
declare enum Severity {
WARNINGS = "warnings",
ERRORS = "errors"
}
declare enum TestSeverity {
Error = "error",
Warning = "warning"
}
declare const TestStatus: {
[x: string]: string;
CANCELED: string;
FAILED: string;
OMITTED: string;
PASSING: string;
SKIPPED: string;
UNTESTED: string;
WARNING: string;
};
type TestStatus = ValueOf;
type TestFnPayload = {
signal: AbortSignal;
};
type TestFn = (payload: TestFnPayload) => TestResult;
type AsyncTest = Promise;
type TestResult = Maybe | void;
type WithFieldName = {
fieldName: F;
};
type TIsolateTest = TIsolate & IsolateTestPayload>;
type IsolateTestPayload = CommonTestFields & {
severity: TestSeverity;
status: TestStatus;
asyncTest?: AsyncTest;
};
type CommonTestFields = {
message?: Maybe;
groupName?: G;
fieldName: F;
testFn: TestFn;
};
declare class SummaryFailure implements WithFieldName {
fieldName: F;
message: string | undefined;
groupName: G | undefined;
constructor(fieldName: F, message: string | undefined, groupName: G | undefined);
static fromTestObject(testObject: TIsolateTest): SummaryFailure;
}
interface Done {
(...args: [
cb: (res: SuiteResult) => void
]): SuiteRunResult;
(...args: [
fieldName: F,
cb: (res: SuiteResult) => void
]): SuiteRunResult;
}
interface SuiteSelectors {
getWarning(): SummaryFailure | undefined;
getWarning(fieldName: F): string | undefined;
getWarning(fieldName?: F): SummaryFailure | string | undefined;
getError(): SummaryFailure | undefined;
getError(fieldName: F): string | undefined;
getError(fieldName?: F): SummaryFailure | string | undefined;
getMessage(fieldName: F): string | undefined;
getErrors(): FailureMessages;
getErrors(fieldName: F): string[];
getErrors(fieldName?: F): string[] | FailureMessages;
getWarnings(): FailureMessages;
getWarnings(fieldName: F): string[];
getWarnings(fieldName?: F): string[] | FailureMessages;
getErrorsByGroup(groupName: G): FailureMessages;
getErrorsByGroup(groupName: G, fieldName: F): string[];
getErrorsByGroup(groupName: G, fieldName?: F): string[] | FailureMessages;
getWarningsByGroup(groupName: G): FailureMessages;
getWarningsByGroup(groupName: G, fieldName: F): string[];
getWarningsByGroup(groupName: G, fieldName?: F): string[] | FailureMessages;
hasErrors(fieldName?: F): boolean;
hasWarnings(fieldName?: F): boolean;
hasErrorsByGroup(groupName: G, fieldName?: F): boolean;
hasWarningsByGroup(groupName: G, fieldName?: F): boolean;
isTested(fieldName: F): boolean;
isPending(fieldName?: F): boolean;
isValid(fieldName?: F): boolean;
isValidByGroup(groupName: G, fieldName?: F): boolean;
}
declare class SummaryBase {
errorCount: number;
warnCount: number;
testCount: number;
pendingCount: number;
}
declare class SuiteSummary extends SummaryBase {
[Severity.ERRORS]: SummaryFailure[];
[Severity.WARNINGS]: SummaryFailure[];
groups: Groups;
tests: Tests;
valid: Nullable;
}
type GroupTestSummary = SingleTestSummary;
type Groups = Record>;
type Group = Record;
type Tests = Record;
type SingleTestSummary = SummaryBase & {
errors: string[];
warnings: string[];
valid: Nullable;
pendingCount: number;
};
type FailureMessages = Record;
type SuiteResult = SuiteSummary & SuiteSelectors & {
suiteName: SuiteName;
};
type SuiteRunResult = SuiteResult & {
done: Done;
};
type SuiteName = Maybe;
type TFieldName = T;
type TGroupName = G;
type OptionalFields = Record;
type OptionalsInput = OneOrMoreOf | OptionalsObject;
type OptionalsObject = Record;
type ImmediateOptionalFieldDeclaration = {
type: OptionalFieldTypes.CUSTOM_LOGIC;
rule: TOptionalRule;
applied: boolean;
};
type DelayedOptionalFieldDeclaration = {
type: OptionalFieldTypes.AUTO;
applied: boolean;
rule: null;
};
type TOptionalRule = DynamicValue;
type OptionalFieldDeclaration = ImmediateOptionalFieldDeclaration | DelayedOptionalFieldDeclaration;
declare enum OptionalFieldTypes {
CUSTOM_LOGIC = 0,
AUTO = 1
}
type TIsolateSuite = TIsolate<{
optional: OptionalFields;
}>;
type Events = "TEST_RUN_STARTED" | "TEST_COMPLETED" | "ALL_RUNNING_TESTS_FINISHED" | "REMOVE_FIELD" | "RESET_FIELD" | "RESET_SUITE" | "SUITE_RUN_STARTED" | "SUITE_CALLBACK_RUN_FINISHED" | "DONE_TEST_OMISSION_PASS";
type Subscribe = {
(event: Events, cb: CB): CB;
(cb: CB): CB;
};
type FieldExclusion = Maybe>;
declare function vestTest(fieldName: F, message: string, cb: TestFn): TIsolateTest;
declare function vestTest(fieldName: F, cb: TestFn): TIsolateTest;
declare function vestTest(fieldName: F, message: string, cb: TestFn, key: IsolateKey): TIsolateTest;
declare function vestTest(fieldName: F, cb: TestFn, key: IsolateKey): TIsolateTest;
declare const test: typeof vestTest & {
memo: TestMemo;
};
type TestMemo = {
(fieldName: F, ...args: ParametersWithoutMessage): TIsolateTest;
(fieldName: F, ...args: ParametersWithMessage): TIsolateTest;
};
type ParametersWithoutMessage = [
test: TestFn,
dependencies: unknown[]
];
type ParametersWithMessage = [
message: string,
test: TestFn,
dependencies: unknown[]
];
type TTypedMethods = {
include: (fieldName: F) => {
when: (condition: F | TDraftCondition) => void;
};
omitWhen: (conditional: TDraftCondition, callback: CB) => void;
only: {
(item: FieldExclusion): void;
};
optional: (optionals: OptionalsInput) => void;
skip: {
(item: FieldExclusion): void;
};
skipWhen: (condition: TDraftCondition, callback: CB) => void;
test: {
(fieldName: F, message: string, cb: TestFn): TIsolateTest;
(fieldName: F, cb: TestFn): TIsolateTest;
(fieldName: F, message: string, cb: TestFn, key: IsolateKey): TIsolateTest;
(fieldName: F, cb: TestFn, key: IsolateKey): TIsolateTest;
} & {
memo: TestMemo;
};
group: {
(callback: () => void): TIsolate;
(groupName: G, callback: () => void): TIsolate;
};
};
type TDraftCondition = DynamicValue
]>;
type StaticSuiteRunResult = Promise> & WithDump & TTypedMethods>;
type WithDump = T & {
dump: CB;
};
type SuiteWithDump = WithDump>;
type Suite = ((...args: Parameters) => SuiteRunResult) & SuiteMethods;
type SuiteMethods = {
dump: CB;
get: CB>;
resume: CB;
reset: CB;
remove: CB;
resetField: CB;
runStatic: CB, Parameters>;
subscribe: Subscribe;
} & TTypedMethods & SuiteSelectors;
type Dumpable = {
dump: CB;
};
declare class SuiteSerializer {
static serialize(suite: Dumpable): string;
static deserialize(serialized: string | TIsolateSuite | Record): TIsolateSuite;
static resume(suite: Suite, root: string | TIsolateSuite | Record): void;
}
export { Dumpable, SuiteSerializer };
//# sourceMappingURL=SuiteSerializer.d.ts.map