intern
Version:
Intern. A next-generation code testing stack for JavaScript.
83 lines (82 loc) • 2.83 kB
TypeScript
import { CancellablePromise } from '@theintern/common';
import Deferred from './Deferred';
import { Executor } from './executors/Executor';
import Test from './Test';
import { InternError } from './types';
import { Remote } from './executors/Node';
export default class Suite implements SuiteProperties {
after: SuiteLifecycleFunction | undefined;
afterEach: TestLifecycleFunction | undefined;
async: ((timeout?: number) => Deferred<void>) | undefined;
before: SuiteLifecycleFunction | undefined;
beforeEach: TestLifecycleFunction | undefined;
error: InternError | undefined;
parent: Suite | undefined;
publishAfterSetup: boolean;
skipped: string | undefined;
tests: (Suite | Test)[];
timeElapsed: number | undefined;
private _bail;
private _executor;
private _name;
private _grep;
private _remote;
private _sessionId;
private _timeout;
constructor(options: SuiteOptions | RootSuiteOptions);
get bail(): boolean;
set bail(value: boolean);
get executor(): Executor;
set executor(value: Executor);
get grep(): RegExp;
set grep(value: RegExp);
get name(): string | undefined;
set name(value: string | undefined);
get id(): string;
get parentId(): string | undefined;
get remote(): Remote;
set remote(value: Remote);
get sessionId(): string;
set sessionId(value: string);
get numTests(): number;
get numPassedTests(): number;
get numFailedTests(): number;
get numSkippedTests(): number;
get hasParent(): boolean;
get timeout(): number;
set timeout(value: number);
add(suiteOrTest: Suite | Test): void;
private _applyGrepToSuiteOrTest;
private _applyGrepToChildren;
run(): CancellablePromise<void>;
skip(message?: string): void;
toJSON(): object;
}
export declare function isSuite(value: any): value is Suite;
export interface SuiteLifecycleFunction {
(this: Suite, suite: Suite): void | PromiseLike<any>;
}
export interface TestLifecycleFunction {
(this: Suite, test: Test, suite: Suite): void | PromiseLike<any>;
}
export interface SuiteProperties {
after: SuiteLifecycleFunction | undefined;
afterEach: TestLifecycleFunction | undefined;
bail: boolean | undefined;
before: SuiteLifecycleFunction | undefined;
beforeEach: TestLifecycleFunction | undefined;
grep: RegExp;
name: string | undefined;
publishAfterSetup: boolean;
timeout: number;
}
export declare type SuiteOptions = Partial<SuiteProperties> & {
name: string;
parent: Suite;
tests?: (Suite | Test)[];
};
export declare type RootSuiteOptions = Partial<SuiteProperties> & {
executor: Executor;
tests?: (Suite | Test)[];
};
export declare type LifecycleMethod = keyof Pick<Suite, 'before' | 'after' | 'beforeEach' | 'afterEach'>;