API reference for Angular CDK testing
import {ContentContainerComponentHarness} from '@angular/cdk/testing';
Classes
ComponentHarness
Base class for component harnesses that all component harness authors should extend. This base component harness provides the basic ability to locate element and sub-component harness. It should be inherited when defining user's own harness.
Properties
Name | Description |
---|---|
|
Methods
documentRootLocatorFactory | |
---|---|
Gets a |
|
Returns | |
LocatorFactory
|
|
async
forceStabilize
|
|
---|---|
Flushes change detection and async tasks in the Angular zone. In most cases it should not be necessary to call this manually. However, there may be some edge cases where it is needed to fully flush animation events. |
async
host
|
|
---|---|
Gets a |
|
Returns | |
Promise<TestElement>
|
|
locatorFor | |
---|---|
Creates an asynchronous locator function that can be used to find a |
|
Parameters | |
queries
|
A list of queries specifying which harnesses and elements to search for:
|
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>>
|
An asynchronous locator function that searches for and returns a e.g. Given the following DOM:
|
locatorForAll | |
---|---|
Creates an asynchronous locator function that can be used to find |
|
Parameters | |
queries
|
A list of queries specifying which harnesses and elements to search for:
|
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>[]>
|
An asynchronous locator function that searches for and returns a e.g. Given the following DOM:
|
locatorForOptional | |
---|---|
Creates an asynchronous locator function that can be used to find a |
|
Parameters | |
queries
|
A list of queries specifying which harnesses and elements to search for:
|
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T> | null>
|
An asynchronous locator function that searches for and returns a e.g. Given the following DOM:
|
async
waitForTasksOutsideAngular
|
|
---|---|
Waits for all scheduled or running async tasks to complete. This allows harness authors to wait for async tasks outside of the Angular zone. |
ContentContainerComponentHarness
extends
ComponentHarness
Base class for component harnesses that authors should extend if they anticipate that consumers
of the harness may want to access other harnesses within the <ng-content>
of the component.
Methods
async
getAllChildLoaders
|
|
---|---|
Parameters | |
selector S
|
|
Returns | |
Promise<HarnessLoader[]>
|
|
async
getAllHarnesses
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T[]>
|
|
async
getChildLoader
|
|
---|---|
Parameters | |
selector S
|
|
Returns | |
Promise<HarnessLoader>
|
|
async
getHarness
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T>
|
|
async
getHarnessOrNull
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T | null>
|
|
async
getRootHarnessLoader
|
|
---|---|
Gets the root harness loader from which to start searching for content contained by this harness. |
|
Returns | |
Promise<HarnessLoader>
|
|
async
hasHarness
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<boolean>
|
|
async
host
|
|
---|---|
Gets a |
|
Returns | |
Promise<TestElement>
|
|
HarnessPredicate
A class used to associate a ComponentHarness class with predicates functions that can be used to filter instances of the class.
Properties
Name | Description |
---|---|
|
Methods
add | |
---|---|
Adds a predicate function to be run against candidate harnesses. |
|
Parameters | |
description string
|
A description of this predicate that may be used in error messages. |
predicate AsyncPredicate<T>
|
An async predicate function. |
addOption | |
---|---|
Adds a predicate function that depends on an option value to be run against candidate harnesses. If the option value is undefined, the predicate will be ignored. |
|
Parameters | |
name string
|
The name of the option (may be used in error messages). |
option O
|
The option value. |
predicate AsyncOptionPredicate<T, O>
|
The predicate function to run if the option value is not undefined. |
async
evaluate
|
|
---|---|
Evaluates whether the given harness satisfies this predicate. |
|
Parameters | |
harness T
|
The harness to check |
Returns | |
Promise<boolean>
|
A promise that resolves to true if the harness satisfies this predicate, and resolves to false otherwise. |
async
filter
|
|
---|---|
Filters a list of harnesses on this predicate. |
|
Parameters | |
harnesses T[]
|
The list of harnesses to filter. |
Returns | |
Promise<T[]>
|
A list of harnesses that satisfy this predicate. |
getDescription | |
---|---|
Gets a description of this predicate for use in error messages. |
getSelector | |
---|---|
Gets the selector used to find candidate elements. |
static
async
stringMatches
|
|
---|---|
Checks if the specified nullable string value matches the given pattern. |
|
Parameters | |
value string | Promise<string>
|
The nullable string value to check, or a Promise resolving to the nullable string value. |
pattern string | RegExp
|
The pattern the value is expected to match. If |
Returns | |
Promise<boolean>
|
Whether the value matches the pattern. |
HarnessEnvironment
Base harness environment class that can be extended to allow ComponentHarness
es to be used in
different test environments (e.g. testbed, protractor, etc.). This class implements the
functionality of both a HarnessLoader
and LocatorFactory
. This class is generic on the raw
element type, E
, used by the particular test environment.
Properties
Name | Description |
---|---|
|
|
|
Methods
createComponentHarness | |
---|---|
Creates a |
|
Parameters | |
harnessType ComponentHarnessConstructor<T>
|
|
element E
|
|
Returns | |
T
|
|
createEnvironment | |
---|---|
Creates a |
|
Parameters | |
element E
|
|
Returns | |
HarnessEnvironment<E>
|
|
createTestElement | |
---|---|
Creates a |
|
Parameters | |
element E
|
|
Returns | |
TestElement
|
|
documentRootLocatorFactory | |
---|---|
Returns | |
LocatorFactory
|
|
async
forceStabilize
|
|
---|---|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getAllChildLoaders
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader[]>
|
|
async
getAllHarnesses
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T[]>
|
|
async
getAllRawElements
|
|
---|---|
Gets a list of all elements matching the given selector under this environment's root element. |
|
Parameters | |
selector string
|
|
Returns | |
Promise<E[]>
|
|
async
getChildLoader
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader>
|
|
getDocumentRoot | |
---|---|
Gets the root element for the document. |
|
Returns | |
E
|
|
async
getHarness
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T>
|
|
async
getHarnessOrNull
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T | null>
|
|
async
harnessLoaderFor
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader>
|
|
async
harnessLoaderForAll
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader[]>
|
|
async
harnessLoaderForOptional
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader | null>
|
|
async
hasHarness
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<boolean>
|
|
locatorFor | |
---|---|
Parameters | |
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>>
|
|
locatorForAll | |
---|---|
Parameters | |
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>[]>
|
|
locatorForOptional | |
---|---|
Parameters | |
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T> | null>
|
|
async
rootHarnessLoader
|
|
---|---|
Returns | |
Promise<HarnessLoader>
|
|
async
waitForTasksOutsideAngular
|
|
---|---|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
Interfaces
HarnessLoader
Interface used to load ComponentHarness objects. This interface is used by test authors to
instantiate ComponentHarness
es.
Methods
async
getAllChildLoaders
|
|
---|---|
Searches for all elements with the given selector under the current instances's root element,
and returns an array of |
|
Parameters | |
selector string
|
The selector for the root element of the new |
Returns | |
Promise<HarnessLoader[]>
|
A list of |
async
getAllHarnesses
|
|
---|---|
Searches for all instances of the component corresponding to the given harness type under the
|
|
Parameters | |
query HarnessQuery<T>
|
A query for a harness to create |
Returns | |
Promise<T[]>
|
A list instances of the given harness type. |
async
getChildLoader
|
|
---|---|
Searches for an element with the given selector under the current instances's root element,
and returns a |
|
Parameters | |
selector string
|
The selector for the root element of the new |
Returns | |
Promise<HarnessLoader>
|
A |
async
getHarness
|
|
---|---|
Searches for an instance of the component corresponding to the given harness type under the
|
|
Parameters | |
query HarnessQuery<T>
|
A query for a harness to create |
Returns | |
Promise<T>
|
An instance of the given harness type |
async
getHarnessOrNull
|
|
---|---|
Searches for an instance of the component corresponding to the given harness type under the
|
|
Parameters | |
query HarnessQuery<T>
|
A query for a harness to create |
Returns | |
Promise<T | null>
|
An instance of the given harness type (or null if not found). |
async
hasHarness
|
|
---|---|
Searches for an instance of the component corresponding to the given harness type under the
|
|
Parameters | |
query HarnessQuery<T>
|
A query for a harness to create |
Returns | |
Promise<boolean>
|
A boolean indicating if an instance was found. |
LocatorFactory
Interface used to create asynchronous locator functions used find elements and component
harnesses. This interface is used by ComponentHarness
authors to create locator functions for
their ComponentHarness
subclass.
Properties
Name | Description |
---|---|
|
The root element of this |
Methods
documentRootLocatorFactory | |
---|---|
Gets a locator factory rooted at the document root. |
|
Returns | |
LocatorFactory
|
|
async
forceStabilize
|
|
---|---|
Flushes change detection and async tasks captured in the Angular zone. In most cases it should not be necessary to call this manually. However, there may be some edge cases where it is needed to fully flush animation events. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
harnessLoaderFor
|
|
---|---|
Gets a |
|
Parameters | |
selector string
|
The selector for the root element. |
Returns | |
Promise<HarnessLoader>
|
A |
async
harnessLoaderForAll
|
|
---|---|
Gets a list of |
|
Parameters | |
selector string
|
The selector for the root element. |
Returns | |
Promise<HarnessLoader[]>
|
A list of |
async
harnessLoaderForOptional
|
|
---|---|
Gets a |
|
Parameters | |
selector string
|
The selector for the root element. |
Returns | |
Promise<HarnessLoader | null>
|
A |
locatorFor | |
---|---|
Creates an asynchronous locator function that can be used to find a |
|
Parameters | |
queries
|
A list of queries specifying which harnesses and elements to search for:
|
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>>
|
An asynchronous locator function that searches for and returns a e.g. Given the following DOM:
|
locatorForAll | |
---|---|
Creates an asynchronous locator function that can be used to find |
|
Parameters | |
queries
|
A list of queries specifying which harnesses and elements to search for:
|
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>[]>
|
An asynchronous locator function that searches for and returns a e.g. Given the following DOM:
|
locatorForOptional | |
---|---|
Creates an asynchronous locator function that can be used to find a |
|
Parameters | |
queries
|
A list of queries specifying which harnesses and elements to search for:
|
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T> | null>
|
An asynchronous locator function that searches for and returns a e.g. Given the following DOM:
|
async
rootHarnessLoader
|
|
---|---|
Returns | |
Promise<HarnessLoader>
|
A |
async
waitForTasksOutsideAngular
|
|
---|---|
Waits for all scheduled or running async tasks to complete. This allows harness authors to wait for async tasks outside of the Angular zone. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
ComponentHarnessConstructor
Constructor for a ComponentHarness subclass.
Properties
Name | Description |
---|---|
|
|
Methods
new | |
---|---|
Parameters | |
locatorFactory LocatorFactory
|
|
Returns | |
T
|
|
BaseHarnessFilters
A set of criteria that can be used to filter a list of ComponentHarness
instances.
Properties
Name | Description |
---|---|
|
Only find instances that are nested under an element with the given selector. |
|
Only find instances whose host element matches the given selector. |
ModifierKeys
Modifier keys that may be held while typing.
Properties
Name | Description |
---|---|
|
|
|
|
|
|
|
TestElement
This acts as a common interface for DOM elements across both unit and e2e tests. It is the interface through which the ComponentHarness interacts with the component's DOM.
Methods
async
blur
|
|
---|---|
Blur the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
clear
|
|
---|---|
Clear the element's input (for input and textarea elements only). |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
---|---|
Click the element at the default location for the current environment. If you need to guarantee
the element is clicked at a specific location, consider using |
|
Parameters | |
modifiers? ModifierKeys
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
dispatchEvent
|
|
---|---|
Dispatches an event with a particular name. |
|
Parameters | |
name string
|
Name of the event to be dispatched. |
data? Record<string, EventData>
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
focus
|
|
---|---|
Focus the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getAttribute
|
|
---|---|
Gets the value for the given attribute from the element. |
|
Parameters | |
name string
|
|
Returns | |
Promise<string | null>
|
|
async
getCssValue
|
|
---|---|
Get the computed value of the given CSS property for the element. |
|
Parameters | |
property string
|
|
Returns | |
Promise<string>
|
|
async
getDimensions
|
|
---|---|
Gets the dimensions of the element. |
|
Returns | |
Promise<ElementDimensions>
|
|
async
getProperty
|
|
---|---|
Gets the value of a property of an element. |
|
Parameters | |
name string
|
|
Returns | |
Promise<T>
|
|
async
hasClass
|
|
---|---|
Checks whether the element has the given class. |
|
Parameters | |
name string
|
|
Returns | |
Promise<boolean>
|
|
async
hover
|
|
---|---|
Hovers the mouse over the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
isFocused
|
|
---|---|
Checks whether the element is focused. |
|
Returns | |
Promise<boolean>
|
|
async
matchesSelector
|
|
---|---|
Checks whether this element matches the given selector. |
|
Parameters | |
selector string
|
|
Returns | |
Promise<boolean>
|
|
async
mouseAway
|
|
---|---|
Moves the mouse away from the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
rightClick
|
|
---|---|
Right clicks on the element at the specified coordinates relative to the top-left of it. |
|
Parameters | |
relativeX number
|
Coordinate within the element, along the X-axis at which to click. |
relativeY number
|
Coordinate within the element, along the Y-axis at which to click. |
modifiers? ModifierKeys
|
Modifier keys held while clicking |
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
selectOptions
|
|
---|---|
Selects the options at the specified indexes inside of a native |
|
Parameters | |
...optionIndexes number[]
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
sendKeys
|
|
---|---|
Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value. Note that some environments cannot reproduce native browser behavior for keyboard shortcuts such as Tab, Ctrl + A, etc. |
|
Parameters | |
...keys (string | TestKey)[]
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
setContenteditableValue
|
|
---|---|
Sets the value of a |
|
Parameters | |
value string
|
Value to be set on the element. |
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
setInputValue
|
|
---|---|
Sets the value of a property of an input. |
|
Parameters | |
value string
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
text
|
|
---|---|
Gets the text from the element. |
|
Parameters | |
options? TextOptions
|
Options that affect what text is included. |
Returns | |
Promise<string>
|
|
TextOptions
Properties
Name | Description |
---|---|
|
Optional selector for elements to exclude. |
ElementDimensions
Dimensions for element size and its position relative to the viewport.
Properties
Name | Description |
---|---|
|
|
|
|
|
|
|
AutoChangeDetectionStatus
Represents the status of auto change detection.
Properties
Name | Description |
---|---|
|
Whether auto change detection is disabled. |
|
An optional callback, if present it indicates that change detection should be run immediately, while handling the status change. The callback should then be called as soon as change detection is done. |
Functions
handleAutoChangeDetectionStatus | |
---|---|
Allows a test |
|
Parameters | |
handler (status: AutoChangeDetectionStatus) => void
|
The handler for the auto change detection status. |
stopHandlingAutoChangeDetectionStatus | |
---|---|
Allows a |
async
manualChangeDetection
|
|
---|---|
Disables the harness system's auto change detection for the duration of the given function. |
|
Parameters | |
fn () => Promise<T>
|
The function to disable auto change detection for. |
async
parallel
|
|
---|---|
Resolves the given list of async values in parallel (i.e. via Promise.all) while batching change detection over the entire operation such that change detection occurs exactly once before resolving the values and once after. |
|
Parameters | |
values () => Iterable<T | PromiseLike<T>>
|
A getter for the async values to resolve in parallel with batched change detection. |
Returns | |
Promise<T[]>
|
The resolved values. |
Type aliases
AsyncFactoryFn
An async function that returns a promise when called.
type AsyncFactoryFn = () => Promise<T>;
AsyncPredicate
An async function that takes an item and returns a boolean promise
type AsyncPredicate = (item: T) => Promise<boolean>;
AsyncOptionPredicate
An async function that takes an item and an option value and returns a boolean promise.
type AsyncOptionPredicate = (item: T, option: O) => Promise<boolean>;
HarnessQuery
A query for a ComponentHarness
, which is expressed as either a ComponentHarnessConstructor
or
a HarnessPredicate
.
type HarnessQuery = ComponentHarnessConstructor<T> | HarnessPredicate<T>;
LocatorFnResult
The result type obtained when searching using a particular list of queries. This type depends on the particular items being queried.
- If one of the queries is for a
ComponentHarnessConstructor<C1>
, it means that the result might be a harness of typeC1
- If one of the queries is for a
HarnessPredicate<C2>
, it means that the result might be a harness of typeC2
- If one of the queries is for a
string
, it means that the result might be aTestElement
.
Since we don't know for sure which query will match, the result type if the union of the types for all possible results.
e.g.
The type:
LocatorFnResult<[
ComponentHarnessConstructor<MyHarness>,
HarnessPredicate<MyOtherHarness>,
string
]>
is equivalent to:
MyHarness | MyOtherHarness | TestElement
.
type LocatorFnResult = {
[I in keyof T]: T[I] extends new (...args: any[]) => infer C ? C : T[I] extends {
harnessType: new (...args: any[]) => infer C;
} ? C : T[I] extends string ? TestElement : never;
}[number];
EventData
Data that can be attached to a custom event dispatched from a TestElement
.
type EventData = string | number | boolean | Function | undefined | null | EventData[] | {
[key: string]: EventData;
};
API reference for Angular CDK testing-testbed
Import symbols from @angular/cdk/testing/testbed
Classes
TestbedHarnessEnvironment
extends
HarnessEnvironment
A HarnessEnvironment
implementation for Angular's Testbed.
Properties
Name | Description |
---|---|
|
Methods
createEnvironment | |
---|---|
Creates a |
|
Parameters | |
element Element
|
|
Returns | |
HarnessEnvironment<Element>
|
|
createTestElement | |
---|---|
Creates a |
|
Parameters | |
element Element
|
|
Returns | |
TestElement
|
|
static
documentRootLoader
|
|
---|---|
Creates a |
|
Parameters | |
fixture ComponentFixture<unknown>
|
|
options? TestbedHarnessEnvironmentOptions
|
|
Returns | |
HarnessLoader
|
|
documentRootLocatorFactory | |
---|---|
Returns | |
LocatorFactory
|
|
async
forceStabilize
|
|
---|---|
Flushes change detection and async tasks captured in the Angular zone. In most cases it should not be necessary to call this manually. However, there may be some edge cases where it is needed to fully flush animation events. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getAllChildLoaders
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader[]>
|
|
async
getAllHarnesses
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T[]>
|
|
async
getAllRawElements
|
|
---|---|
Gets a list of all elements matching the given selector under this environment's root element. |
|
Parameters | |
selector string
|
|
Returns | |
Promise<Element[]>
|
|
async
getChildLoader
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader>
|
|
getDocumentRoot | |
---|---|
Gets the root element for the document. |
|
Returns | |
Element
|
|
async
getHarness
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T>
|
|
async
getHarnessOrNull
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<T | null>
|
|
static
getNativeElement
|
|
---|---|
Gets the native DOM element corresponding to the given TestElement. |
|
Parameters | |
el TestElement
|
|
Returns | |
Element
|
|
static
async
harnessForFixture
|
|
---|---|
Creates an instance of the given harness type, using the fixture's root element as the harness's host element. This method should be used when creating a harness for the root element of a fixture, as components do not have the correct selector when they are created as the root of the fixture. |
|
Parameters | |
fixture ComponentFixture<unknown>
|
|
harnessType ComponentHarnessConstructor<T>
|
|
options? TestbedHarnessEnvironmentOptions
|
|
Returns | |
Promise<T>
|
|
async
harnessLoaderFor
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader>
|
|
async
harnessLoaderForAll
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader[]>
|
|
async
harnessLoaderForOptional
|
|
---|---|
Parameters | |
selector string
|
|
Returns | |
Promise<HarnessLoader | null>
|
|
async
hasHarness
|
|
---|---|
Parameters | |
query HarnessQuery<T>
|
|
Returns | |
Promise<boolean>
|
|
static
loader
|
|
---|---|
Creates a |
|
Parameters | |
fixture ComponentFixture<unknown>
|
|
options? TestbedHarnessEnvironmentOptions
|
|
Returns | |
HarnessLoader
|
|
locatorFor | |
---|---|
Parameters | |
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>>
|
|
locatorForAll | |
---|---|
Parameters | |
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T>[]>
|
|
locatorForOptional | |
---|---|
Parameters | |
...queries T
|
|
Returns | |
AsyncFactoryFn<LocatorFnResult<T> | null>
|
|
async
rootHarnessLoader
|
|
---|---|
Returns | |
Promise<HarnessLoader>
|
|
async
waitForTasksOutsideAngular
|
|
---|---|
Waits for all scheduled or running async tasks to complete. This allows harness authors to wait for async tasks outside of the Angular zone. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
UnitTestElement
A TestElement
implementation for unit tests.
Properties
Name | Description |
---|---|
|
Methods
async
blur
|
|
---|---|
Blur the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
clear
|
|
---|---|
Clear the element's input (for input and textarea elements only). |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
---|---|
Click the element at the default location for the current environment. If you need to guarantee
the element is clicked at a specific location, consider using |
|
Parameters | |
modifiers? ModifierKeys
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
---|---|
Click the element at the element's center. |
|
Parameters | |
location "center"
|
|
modifiers? ModifierKeys
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
---|---|
Click the element at the specified coordinates relative to the top-left of the element. |
|
Parameters | |
relativeX number
|
Coordinate within the element, along the X-axis at which to click. |
relativeY number
|
Coordinate within the element, along the Y-axis at which to click. |
modifiers? ModifierKeys
|
Modifier keys held while clicking |
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
dispatchEvent
|
|
---|---|
Dispatches an event with a particular name. |
|
Parameters | |
name string
|
Name of the event to be dispatched. |
data? Record<string, EventData>
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
focus
|
|
---|---|
Focus the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getAttribute
|
|
---|---|
Gets the value for the given attribute from the element. |
|
Parameters | |
name string
|
|
Returns | |
Promise<string | null>
|
|
async
getCssValue
|
|
---|---|
Get the computed value of the given CSS property for the element. |
|
Parameters | |
property string
|
|
Returns | |
Promise<string>
|
|
async
getDimensions
|
|
---|---|
Gets the dimensions of the element. |
|
Returns | |
Promise<ElementDimensions>
|
|
async
getProperty
|
|
---|---|
Gets the value of a property of an element. |
|
Parameters | |
name string
|
|
Returns | |
Promise<T>
|
|
async
hasClass
|
|
---|---|
Checks whether the element has the given class. |
|
Parameters | |
name string
|
|
Returns | |
Promise<boolean>
|
|
async
hover
|
|
---|---|
Hovers the mouse over the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
isFocused
|
|
---|---|
Checks whether the element is focused. |
|
Returns | |
Promise<boolean>
|
|
async
matchesSelector
|
|
---|---|
Checks whether this element matches the given selector. |
|
Parameters | |
selector string
|
|
Returns | |
Promise<boolean>
|
|
async
mouseAway
|
|
---|---|
Moves the mouse away from the element. |
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
rightClick
|
|
---|---|
Parameters | |
...args [ModifierKeys?] | ["center", ModifierKeys?] | [number, number, ModifierKeys?]
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
selectOptions
|
|
---|---|
Selects the options at the specified indexes inside of a native |
|
Parameters | |
...optionIndexes number[]
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
sendKeys
|
|
---|---|
Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value. Note that this cannot reproduce native browser behavior for keyboard shortcuts such as Tab, Ctrl + A, etc. |
|
Parameters | |
...keys (string | TestKey)[]
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
sendKeys
|
|
---|---|
Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value. |
|
Parameters | |
modifiers ModifierKeys
|
|
...keys (string | TestKey)[]
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
setContenteditableValue
|
|
---|---|
Sets the value of a |
|
Parameters | |
value string
|
Value to be set on the element. |
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
setInputValue
|
|
---|---|
Sets the value of a property of an input. |
|
Parameters | |
value string
|
|
Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
text
|
|
---|---|
Gets the text from the element. |
|
Parameters | |
options? TextOptions
|
Options that affect what text is included. |
Returns | |
Promise<string>
|
|
Interfaces
TestbedHarnessEnvironmentOptions
Options to configure the environment.
Properties
Name | Description |
---|---|
|
The query function used to find DOM elements. |