import RuntimeContext from '../runtime_context'; import { Done } from './interface'; /** * Passed to TestFunction callback for async test cases to signal they're done. */ export { Done }; /** * Callback function used for tests and hooks with a context with typed `attributes`. */ export type Func = (this: Context, done: Done) => void; /** * Async callback function used for tests and hooks with a context with typed `attributes`. */ export type AsyncFunc = (this: Context) => PromiseLike; export interface HookFunction { /** * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the * function is used as the name of the hook. * * - _Only available when invoked via Overman._ */ (fn: Func): void; /** * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the * function is used as the name of the hook. * * - _Only available when invoked via Overman._ */ (fn: AsyncFunc): void; /** * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. * * - _Only available when invoked via Overman._ */ (name: string, fn?: Func): void; /** * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. * * - _Only available when invoked via Overman._ */ (name: string, fn?: AsyncFunc): void; } interface BaseSuiteFunction { /** * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing * nested suites. * * - _Only available when invoked via Overman._ */ (title: string, fn: (this: SuiteContext) => void): void; /** * [qunit] Describe a "suite" with the given `title`. * * - _Only available when invoked via Overman._ */ (title: string): void; /** * Describe a specification or test-case with the given `title`, `attributes` and callback * `fn` acting as a thunk. * * - _Only available when invoked via Overman._ */ >(title: string, attributes: U, fn: (this: SuiteContext) => void): void; /** * Describe a specification or test-case with the given `title`, `attributes` and callback * `fn` acting as a thunk. * * - _Only available when invoked via Overman._ */ >(title: string, attributes: U): void; } export interface ExclusiveSuiteFunction extends BaseSuiteFunction { } export interface PendingSuiteFunction extends BaseSuiteFunction { } export interface UnstableSuiteFunction extends BaseSuiteFunction { } export interface SuiteFunction extends BaseSuiteFunction { /** * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. * * - _Only available when invoked via Overman._ */ only: ExclusiveSuiteFunction; /** * [bdd, tdd] Indicates this suite should not be executed. * * - _Only available when invoked via Overman._ */ skip: PendingSuiteFunction; /** * [bdd, tdd] Indicates this suite is unstable. * * - _Only available when invoked via Overman._ */ unstable: PendingSuiteFunction; } interface BaseTestFunction { /** * Describe a specification or test-case with the given `title` and callback `fn` acting * as a thunk. * * - _Only available when invoked via Overman._ */ (title: string, fn?: Func): void; /** * Describe a specification or test-case with the given `title` and callback `fn` acting * as a thunk. * * - _Only available when invoked via Overman._ */ (title: string, fn?: AsyncFunc): void; /** * Describe a specification or test-case with the given `title`, `attributes` and callback * `fn` acting as a thunk. * * - _Only available when invoked via Overman._ */ >(title: string, attributes: U, fn?: Func): void; /** * Describe a specification or test-case with the given `title`, `attributes` and callback * `fn` acting as a thunk. * * - _Only available when invoked via Overman._ */ >(title: string, attributes: U, fn?: AsyncFunc): void; } export interface ExclusiveTestFunction extends BaseTestFunction { } export interface PendingTestFunction extends BaseTestFunction { } export interface UnstableTestFunction extends BaseTestFunction { } export interface TestFunction extends BaseTestFunction { /** * Indicates this test should be executed exclusively. * * - _Only available when invoked via Overman._ */ only: ExclusiveTestFunction; /** * Indicates this test should not be executed. * * - _Only available when invoked via Overman._ */ skip: PendingTestFunction; /** * Indicates this test is unstable. * * - _Only available when invoked via Overman._ */ unstable: UnstableTestFunction; } /** * */ export type SuiteParameters = { timeout?: number; slow?: number; }; /** * Suite context */ export interface SuiteContext { attributes: T; /** * Get timeout & slow. */ getParameters(): SuiteParameters; /** * Get test timeout. */ timeout(): number | null; /** * Set test timeout. */ timeout(ms: number): void; /** * Get test slowness threshold. */ slow(): number | null; /** * Set test slowness threshold. */ slow(ms: number): void; /** * Execute before running tests. * * - _Only available when invoked via Overman._ */ before: HookFunction; /** * Execute after running tests. * * - _Only available when invoked via Overman._ */ after: HookFunction; /** * Execute before each test case. * * - _Only available when invoked via Overman._ */ beforeEach: HookFunction; /** * Execute after each test case. * * - _Only available when invoked via Overman._ */ afterEach: HookFunction; /** * Describe a nested "suite". * * - _Only available when invoked via Overman._ */ describe: SuiteFunction; /** * Describes a nested test case. * * - _Only available when invoked via Overman._ */ it: TestFunction; } export declare class SuiteContextImpl implements SuiteContext { private _parentContext; readonly attributes: T; private _parameters; before: Overman.HookFunction; after: Overman.HookFunction; beforeEach: Overman.HookFunction; afterEach: Overman.HookFunction; describe: Overman.SuiteFunction; it: Overman.TestFunction; constructor(_parentContext: SuiteContextImpl | undefined, attributes: T); getParameters(): SuiteParameters; timeout(timeout: number): undefined; timeout(): number | null; slow(slow: number): undefined; slow(): number | null; } /** * Test context */ export declare class Context { private runtimeContext?; title: string; currentTest: Context; constructor(runtimeContext?: RuntimeContext | undefined); get attributes(): T; fullTitle(): string; /** * Get test timeout. */ timeout(): number; /** * Set test timeout. */ timeout(ms: number): void; /** * Get test slowness threshold. */ slow(): number; /** * Set test slowness threshold. */ slow(ms: number): void; /** * Leave a breadcrumb to be printed in error for any failing assertions. */ breadcrumb(messageOrError: string | Error): void; /** * Emit debug information. */ debugInfo(name: string, value: U): void; }