@o3r/testing
Version:
The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.
111 lines • 6.11 kB
TypeScript
import type { ComponentFixtureProfile } from '../component-fixture';
import { O3rElement, O3rElementConstructor } from './element';
import { O3rGroup, O3rGroupConstructor } from './group';
export type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';
/**
* Implementation of the fixture dedicated to Playwright, hence using the webdriver to interact with the dom.
*/
export declare class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {
/**
* DOM element linked to the fixture.
*/
protected rootElement: V;
/**
* Root element of this fixture.
* All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.
* @param rootElement
*/
constructor(rootElement: V);
/**
* Throws an exception if the element is undefined.
* Otherwise returns the element.
* @param element ElementProfile to test
* @param timeout specific timeout that will throw when reach
*/
protected throwOnUndefinedElement<T extends O3rElement>(element?: T, timeout?: number): Promise<T>;
/**
* Throws an exception if the element is undefined.
* Otherwise returns the element.
* @param element ElementProfile to test
* @param timeout specific timeout that will throw when reach
*/
protected throwOnUndefined<T extends O3rElement>(element: Promise<T>, timeout?: number): Promise<T>;
/**
* Get the element associated to the selector if present
* @param selector Selector to access the element
* @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
* @param options Options supported
* @param options.index index Select the element associated to the index
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
* @param options.timeout Duration to wait for the element to be present before it throws
*/
protected queryWithOptions(selector: string, elementConstructor?: O3rElementConstructor<O3rElement>, options?: {
index?: number;
shouldThrowIfNotPresent?: boolean;
timeout?: number;
}): Promise<O3rElement>;
/**
* Get text from the element associated to the given selector, or undefined if the element is not found or not visible
* @param selector Selector to access the element
* @param options Options supported
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
* @param options.index index Select the element associated to the index
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
* @param options.timeout Duration to wait for the element to be present before it throws
*/
protected getText<T extends O3rElement>(selector: string, options?: {
elementConstructor?: O3rElementConstructor<T>;
index?: number;
shouldThrowIfNotPresent?: boolean;
timeout?: number;
}): Promise<string | undefined>;
/**
* Check if the element associated to the given selector is visible
* @param selector Selector to access the element
* @param options Options supported
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
* @param options.index index Select the element associated to the index
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
* @param options.timeout Duration to wait for the element to be present before it throws
*/
protected isVisible<T extends O3rElement>(selector: string, options?: {
elementConstructor?: O3rElementConstructor<T> | undefined;
index?: number;
shouldThrowIfNotPresent?: boolean;
timeout?: number;
}): Promise<boolean>;
/**
* Click on the element associated to the given selector if it exists and is visible
* @param selector Selector to access the element
* @param options Options supported
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
* @param options.index index Select the element associated to the index
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
* @param options.timeout Duration to wait for the element to be present before it throws
*/
protected click<T extends O3rElement>(selector: string, options?: {
elementConstructor?: O3rElementConstructor<T> | undefined;
index?: number;
shouldThrowIfNotPresent?: boolean;
timeout?: number;
}): Promise<void>;
/** @inheritdoc */
query(selector: string, returnType?: undefined): Promise<O3rElement>;
query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T>;
/** @inheritdoc */
queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement>;
queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T>;
/** @inheritdoc */
queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;
queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;
queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;
/** @inheritdoc */
getElement(): V;
/** @inheritdoc */
getSubComponents(): Promise<{
[componentName: string]: ComponentFixtureProfile[];
}>;
/** @inheritDoc */
queryNotPresent(selector: string): Promise<boolean>;
}
//# sourceMappingURL=component-fixture.d.ts.map