import { Location, TestStepInfo } from "@playwright/test"; //#region src/playwright-step-decorator.d.ts type StepMethod = (this: This, ...args: Args) => Promise; type NonFunctionValue = T extends ((...args: unknown[]) => unknown) ? never : T; type StepOptions = { box?: boolean; location?: Location; timeout?: number; }; /** * Returns a resolved promise for non-async `@step` methods. */ export declare function stepResult(): Promise; export declare function stepResult(factory: () => T): Promise>; export declare function stepResult(value: NonFunctionValue): Promise>; /** * Decorator to wrap a promise-returning method in a Playwright step with a dynamic description. * * If no description is provided, the step will use the format: `ClassName.methodName`. * * Placeholders in the description (e.g. `{{user.name}}` or `[[0]]`) will be replaced with actual argument values at runtime. * * @template This The type of the class instance. * @template Args The argument types of the decorated method. * @template ReturnType The return type of the decorated method. * @param descriptionOrOptions Optional step description, or Playwright step options when no description is needed. * @param options Optional Playwright step options when a description string is provided. If `location` is omitted, the decorator captures the current call site automatically. * @returns A decorator function that wraps the target method in a Playwright step. * * @example * ```typescript * class MyTest { * @step("Login as {{user.name}}") * async login(user: { name: string }) { ... } * * @step("Click button [[0]] times") * async clickButton(times: number) { ... } * * @step("Reset the form") * resetForm(): Promise { return stepResult(); } // No `async` keyword needed (avoids require-await) * * @step("Build greeting for {{name}}") * buildGreeting(name: string): Promise { * return stepResult(`Hello ${name}`); * } * * @step("Prepare greeting for {{name}}") * prepareGreeting(name: string): Promise { * return stepResult(() => { * const greeting = `Hello ${name}`; * return greeting.toUpperCase(); * }); * } * * @step() * async defaultStep() { ... } // Step will be "MyTest.defaultStep" * } * ``` * * @throws {Error} If placeholders reference missing or out-of-bounds parameters. * @throws {Error} If property access in a placeholder is invalid. */ export declare function step(): ReturnType; export declare function step(options: StepOptions): ReturnType; export declare function step(description: string, options?: StepOptions): ReturnType; declare function createStepDecorator(description?: string, options?: StepOptions): (target: StepMethod, context: ClassMethodDecoratorContext>) => (this: This, ...args: Args) => Promise; /** * Retrieves the `TestStepInfo` associated with the current Step Decorator call. * * This function reads the step context from async-local storage. The optional instance parameter * is retained for backwards compatibility with earlier versions that stored the step on `this`. * If the step context is not found, it throws an error indicating that the method should be decorated with `@step`. * * @returns The `TestStepInfo` associated with the instance. * @throws {Error} If no Playwright step context is found on the instance. */ export declare function getStepInfo(): TestStepInfo; export declare function getStepInfo(instance: unknown): TestStepInfo; //#endregion //# sourceMappingURL=index.d.mts.map