@o3r/testing
Version:
The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.
115 lines • 6.34 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 angular, hence using angular testing framework.
*/
export declare class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {
/**
* DOM element linked to the fixture.
*/
protected element: V;
/**
* Root element of this fixture. It will be used as the context for further queries.
* @param element
*/
constructor(element: 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 | undefined>, 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: undefined, options: {
index?: number;
shouldThrowIfNotPresent?: boolean;
timeout?: number;
}): Promise<O3rElement | undefined>;
protected queryWithOptions<T extends O3rElement>(selector: string, elementConstructor: O3rElementConstructor<T>, options: {
index?: number;
shouldThrowIfNotPresent?: boolean;
timeout?: number;
}): Promise<T | undefined>;
/**
* 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> | undefined;
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 | undefined>;
query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;
/** @inheritdoc */
queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;
queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;
/** @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, _timeout?: number): Promise<boolean>;
}
//# sourceMappingURL=component-fixture.d.ts.map