import { type IPreTaskFunction } from './tapbundle.classes.pretask.js'; import { type IPostTaskFunction } from './tapbundle.classes.posttask.js'; import { TapTest, type ITestFunction } from './tapbundle.classes.taptest.js'; import type { ITapSettings } from './tapbundle.interfaces.js'; export interface ITestSuite { description: string; tests: TapTest[]; beforeAll?: ITestFunction; afterAll?: ITestFunction; beforeEach?: ITestFunction; afterEach?: ITestFunction; parent?: ITestSuite; children: ITestSuite[]; } declare class TestBuilder { private _tap; private _tags; private _priority; private _retryCount?; private _timeoutMs?; private _parallel; constructor(tap: Tap, parallel?: boolean); tags(...tags: string[]): this; priority(level: 'high' | 'medium' | 'low'): this; retry(count: number): this; timeout(ms: number): this; test(description: string, testFunction: ITestFunction): TapTest; testOnly(description: string, testFunction: ITestFunction): TapTest; testSkip(description: string, testFunction: ITestFunction): TapTest; } export declare class Tap { private protocolEmitter; private settingsManager; private _skipCount; private _filterTags; private _cleanupFunctions; constructor(); /** * Register a cleanup function to be called when tap.start() finishes. * Use this to tear down resources that would otherwise keep the event loop alive. */ registerCleanup(fn: () => Promise | void): void; tags(...tags: string[]): TestBuilder; priority(level: 'high' | 'medium' | 'low'): TestBuilder; retry(count: number): TestBuilder; timeout(ms: number): TestBuilder; parallel(): TestBuilder; /** * skips a test * tests marked with tap.skip.test() are never executed */ skip: { test: (descriptionArg: string, functionArg: ITestFunction) => TapTest; testParallel: (descriptionArg: string, functionArg: ITestFunction) => TapTest; }; /** * only executes tests marked as ONLY */ only: { test: (descriptionArg: string, testFunctionArg: ITestFunction) => TapTest; testParallel: (descriptionArg: string, testFunctionArg: ITestFunction) => TapTest; }; /** * mark a test as todo (not yet implemented) */ todo: { test: (descriptionArg: string, functionArg?: ITestFunction) => TapTest; testParallel: (descriptionArg: string, functionArg?: ITestFunction) => TapTest; }; private _tapPreTasks; private _tapPostTasks; private _tapTests; private _tapTestsOnly; private _currentSuite; private _rootSuites; /** * Configure global test settings */ settings(settings: ITapSettings): this; /** * Get current test settings */ getSettings(): ITapSettings; /** * Normal test function, will run one by one * @param testDescription - A description of what the test does * @param testFunction - A Function that returns a Promise and resolves or rejects */ test(testDescription: string, testFunction: ITestFunction, modeArg?: 'normal' | 'only' | 'skip'): TapTest; preTask(descriptionArg: string, functionArg: IPreTaskFunction): void; postTask(descriptionArg: string, functionArg: IPostTaskFunction): void; /** * A parallel test that will not be waited for before the next starts. * @param testDescription - A description of what the test does * @param testFunction - A Function that returns a Promise and resolves or rejects */ testParallel(testDescription: string, testFunction: ITestFunction): TapTest; /** * Create a test suite for grouping related tests */ describe(description: string, suiteFunction: () => void): void; /** * Set up a function to run once before all tests in the current suite */ beforeAll(setupFunction: ITestFunction): void; /** * Set up a function to run once after all tests in the current suite */ afterAll(teardownFunction: ITestFunction): void; /** * Set up a function to run before each test in the current suite */ beforeEach(setupFunction: ITestFunction): void; /** * Set up a function to run after each test in the current suite */ afterEach(teardownFunction: ITestFunction): void; /** * collect all tests from suites */ private _collectTests; /** * starts the test evaluation */ start(optionsArg?: { throwOnError: boolean; }): Promise; /** * Emit an event */ private emitEvent; /** * Run tests in a suite with lifecycle hooks */ private _runSuite; stopForcefully(codeArg?: number, directArg?: boolean): Promise; /** * handle errors */ threw(err: Error): void; /** * Explicitly fail the current test with a custom message * @param message - The failure message to display */ fail(message?: string): never; } export declare const tap: Tap; export {};