import Macroable from '@poppinss/macroable'; import { type Test } from '../test/main.js'; import { type Refiner } from '../../refiner/main.js'; import { type Emitter } from '../emitter.js'; import type { GroupHooksHandler, TestHooksHandler, GroupOptions, RunnerListGroupNode } from '../../types.js'; /** * Group class exposes an API to group multiple tests together * and bulk configure them. * * NOTE: Nested groups are not supported on purpose. * * @example * const group = new Group('addition', emitter, refiner) * const test = new Test('2 + 2 = 4', emitter, refiner) * * group.add(test) * await group.exec() */ export declare class Group extends Macroable { #private; title: string; /** * Know if one or more tests/hooks within this group * has failed. */ get failed(): boolean; options: GroupOptions; /** * An array of tests registered under the given group */ tests: Test[]; /** * Shortcut methods to configure tests */ each: { setup: (handler: TestHooksHandler) => void; teardown: (handler: TestHooksHandler) => void; timeout: (timeout: number) => void; retry: (retries: number) => void; skip: (skip?: boolean | (() => Promise | boolean), skipReason?: string) => void; disableTimeout: () => void; }; constructor(title: string, emitter: Emitter, refiner: Refiner); /** * Enable/disable the bail mode. In bail mode, all * upcoming tests will be skipped when the current * test fails * * @param toggle - Whether to enable or disable the bail mode * @returns The group with the bail mode enabled or disabled */ bail(toggle?: boolean): this; /** * Add a test to the group. Adding a test to the group * mutates the test properties * * @param test - The test to add to the group */ add(test: Test): this; /** * Tap into each test and configure it * * @param callback - The function to call before running the test executor callback */ tap(callback: (test: Test) => void): this; /** * Define setup hook for the group * * @param handler - The function to call before running the test executor callback */ setup(handler: GroupHooksHandler): this; /** * Define teardown hook for the group * * @param handler - The function to call after running the test executor callback */ teardown(handler: GroupHooksHandler): this; /** * Execute group hooks and tests * * @returns A promise that resolves when the group has been executed */ exec(): Promise; /** * Return JSON representation of the group */ toJSON(): RunnerListGroupNode; }