import Macroable from '@poppinss/macroable'; import { Test } from '../test/main.js'; import { type Emitter } from '../emitter.js'; import { type Refiner } from '../../refiner/main.js'; import { Group } from '../group/main.js'; import type { SuiteHooksHandler, RunnerListSuiteNode } from '../../types.js'; /** * The Suite class exposes the API to run a group of tests * or independent tests together as part of a suite. * * You can think of suites as * - unit tests suite * - e2e tests suites * - and so on * * @example * const suite = new Suite('unit', emitter) * const group = new Group('addition', emitter, refiner) * const test = new Test('2 + 2 = 4', emitter, refiner) * * suite.add(group) * group.add(test) * * // Runs all the tests inside the registered group * await suite.exec() */ export declare class Suite extends Macroable { #private; readonly name: string; /** * A collection of tests and groups both */ stack: (Test | Group)[]; /** * Number of files in the suite */ get filesCount(): number; /** * List of files in the suite. * Note that this is a copy of the original array to prevent external mutations. */ get files(): string[]; /** * Know if one or more groups or tests within this suite * has failed. */ get failed(): boolean; /** * @param name The name of the suite. * @param files The list of files aggregated for that suite. This comes directly from the backend * @param emitter The emitter to use. * @param refiner The test refiner. */ constructor(name: string, files: string[], emitter: Emitter, refiner: Refiner); /** * Add a test or a group to the execution stack * * @param testOrGroup - The test or group to add to the execution stack */ add(testOrGroup: Test | Group): this; /** * Tap into each test and configure it * * @param callback - The function to call before running the test executor callback */ onTest(callback: (test: Test) => void): this; /** * Tap into each group and configure it * * @param callback - The function to call before running the test executor callback */ onGroup(callback: (group: Group) => void): this; /** * Enable/disable the bail mode. In bail mode, all * upcoming tests/group will be skipped when the current * test fails * * @param toggle - Whether to enable or disable the bail mode * @returns The suite with the bail mode enabled or disabled */ bail(toggle?: boolean): this; /** * Register a test setup function * * @param handler - The function to call before running the test executor callback */ setup(handler: SuiteHooksHandler): this; /** * Register a test teardown function * * @param handler - The function to call after running the test executor callback */ teardown(handler: SuiteHooksHandler): this; /** * Execute suite groups, tests and hooks */ exec(): Promise; /** * Return JSON representation of the suite */ toJSON(): RunnerListSuiteNode; }