import EventEmitter from 'events'; import { PassThrough, Writable } from 'stream'; type EventsType = { PASSED: 'passed'; FAILED: 'failed'; SKIPPED: 'skipped'; STARTED: 'started'; FINISHED: 'finished'; }; type zUnitReporter = { withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; }; type zUnitOptions = Partial<{ timeout: number; exclusive: boolean; skip: boolean; reason: string; pattern: RegExp; directory: string; }>; declare class Runnable extends EventEmitter.EventEmitter { constructor(name: string); name: string; description: string; } type zUnitSyntax = { describe: typeof describe; xdescribe: typeof xdescribe; odescribe: typeof odescribe; it: typeof it; xit: typeof xit; oit: typeof oit; before: typeof before; beforeEach: typeof beforeEach; after: typeof after; afterEach: typeof afterEach; include: typeof include; }; type OutcomesType = { PASSED: 'passed'; FAILED: 'failed'; SKIPPED: 'skipped'; }; declare class GraphNode { type: 'suite' | 'test'; name: string; description: string; point: number; parent: GraphNode | null; children: GraphNode[]; result: 'PASSED' | 'FAILED' | 'SKIPPED'; errors: Error[]; reason: string; stats: { tests: number; passed: number; failed: number; skipped: number; duration: number; }; incomplete: boolean; constructor(type: 'suite' | 'test', name: string, description: string, point: number, parent?: GraphNode); isSuite(): boolean; isTest(): boolean; passed: boolean; failed: boolean; skipped: boolean; resolve(...indexes: number[]): GraphNode; add(...additions: GraphNode[]): this; add(additions: GraphNode[]): this; finish({ result, errors, reason, stats, }: { result: 'PASSED' | 'FAILED' | 'SKIPPED'; errors: Error[]; reason: string; stats: { tests: number; passed: number; failed: number; skipped: number; duration: number; }; }): void; private _orphan(): GraphNode; } export const Events: EventsType; export class Harness extends EventEmitter.EventEmitter { constructor(testable: Testable, initial?: Pick); numberOfTests: number; report: GraphNode; run(reporter: zUnitReporter, runtime?: Pick): Promise; } type SuiteApi = { name: string; locals: Locals; skip?: (reason?: string) => void; }; type SuiteHookApi = { name: string; suite: SuiteApi; }; type TestApi = { name: string; suite: SuiteApi; locals: Locals; skip?: (reason?: string) => void; }; type TestHookApi = { name: string; test: TesApi; }; type SuiteFunction = () => void; type SuiteHookFunction = (hook: SuiteHookApi, done: Function) => void; type TestFunction = (test: TestApi, done: Function) => void; type TestHookFunction = (hook: TestHookApi, done: Function) => void; export class Hook extends Runnable { constructor(name: string, fn: SuiteHookFunction | TestHookFunction, initial?: Pick); name: string; run(propagatedOptions: Pick): Promise; } export class HookSet { addBefores(...additions: Hook[]): this; addBefores(additions: Hook[]): this; addAfters(...additions: Hook[]): this; addAfters(additions: Hook[]): this; runBefores(options: zUnitOptions): Promise; runAfters(options: zUnitOptions): Promise; } export class Options { constructor(options?: zUnitOptions); defaults: zUnitOptions; initial: zUnitOptions; runtime: zUnitOptions; bequeathed: zUnitOptions; get(name: T): U; export(): zUnitOptions; apply(other: zUnitOptions): this; bequeath(options: zUnitOptions): void; } export const Outcomes: OutcomesType; export class Suite extends Testable { constructor(name: string, initial?: zUnitOptions); pending: boolean; numberOfTests: number; numberOfPasses: number; numberOfFailures: number; numberOfSkipped: number; discover( runtime?: Partial<{ directory: string; pattern: RegExp; filter: (str: string) => boolean; }> ): Promise; hasExclusiveTests(): boolean; hasFailures(): boolean; before(...additions: Hook[]): this; before(additions: Hook[]): this; beforeEach(...additions: Hook[]): this; beforeEach(additions: Hook[]): this; after(...additions: Hook[]): this; after(additions: Hook[]): this; afterEach(...additions: Hook[]): this; afterEach(additions: Hook[]): this; add(...additions: Testable[]): this; add(additions: Testable[]): this; run(reporter: zUnitReporter, propagatedOptions: zUnitOptions, force?: boolean): Promise; } export class Test extends Testable { constructor(name: string, fn: TestFunction, initial?: Pick); point: number; numberOfTests: number; numberOfPasses: number; numberOfFailures: number; numberOfSkipped: number; pending: boolean; hasExclusiveTests(): boolean; run(reporter: zUnitReporter, propagatedOptions: Pick): Promise; } export class Testable extends Runnable { constructor(...args: string[]); passed: boolean; failed: boolean; skipped: boolean; reason: string; stats: { tests: number; passed: number; failed: number; skipped: number; duration: number; }; exclusive: boolean; } export const syntax: zUnitSyntax; export function describe(name: string, fn: SuiteFunction, options?: Pick): Suite; export function xdescribe(name: string, fn: SuiteFunction, options?: Pick): Suite; export function odescribe(name: string, fn: SuiteFunction, options?: Pick): Suite; export function it(name: string, fn: TestFunction, options?: Pick): void; export function xit(name: string, fn: TestFunction, options?: Pick): void; export function oit(name: string, fn: TestFunction, options?: Pick): void; export function before(name: string, fn: SuiteHookFunction, options?: Pick): void; export function before(fn: SuiteHookFunction, options?: Pick): void; export function beforeEach(name: string, fn: TestHookFunction, options?: Pick): void; export function beforeEach(fn: TestHookFunction, options?: Pick): void; export function after(name: string, fn: SuiteHookFunction, options?: Pick): void; export function after(fn: SuiteHookFunction, options?: Pick): void; export function afterEach(name: string, fn: TestHookFunction, options?: Pick): void; export function afterEach(fn: TestHookFunction, options?: Pick): void; export function include(...testables: Testable[]): void; export function include(testables: Testable[]): void; export class GraphReporter implements zUnitReporter { constructor(name?: string); withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; toGraph(): GraphNode; } export class MultiReporter implements zUnitReporter { constructor(level?: number); withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; add(...additions: Reporter[]): this; add(additions: Reporter[]): this; } export class NullReporter implements zUnitReporter { withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; } export class SpecReporter extends StreamReporter { constructor( options?: Partial<{ stream: Writable; colours: boolean; colors: boolean; }>, level?: number ); withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; } export class StreamReporter implements zUnitReporter { constructor(options?: unknown); stream: PassThrough; end(): void; } export class SurefireReporter extends StreamReporter { constructor( options?: Partial<{ stream: Writable; }> ); withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; } export class TapReporter extends StreamReporter { constructor( options?: Partial<{ stream: Writable; }> ); withHarness(harness: Harness): Harness; withSuite(suite: Suite): Suite; withTest(test: Test): Test; } export class Locals { get(name: string): any; set(name: string, value: any): void; del(name: string): void; }