• Overview
@angular/cdk/testing/testbed

UnitTestElement

Class

A TestElement implementation for unit tests.

API

  
    class UnitTestElement implements TestElement {
}

constructor

UnitTestElement
@paramelementElement
@param_stabilize() => Promise<void>

blur

Promise<void>

Blur the element.

@returnsPromise<void>

clear

Promise<void>

Clear the element's input (for input and textarea elements only).

@returnsPromise<void>

click

3 overloads

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 click('center') or click(x, y) instead.

@parammodifiersany
@returnsPromise<void>

Click the element at the element's center.

@paramlocation"center"
@parammodifiersany
@returnsPromise<void>

Click the element at the specified coordinates relative to the top-left of the element.

@paramrelativeXnumber

Coordinate within the element, along the X-axis at which to click.

@paramrelativeYnumber

Coordinate within the element, along the Y-axis at which to click.

@parammodifiersany

Modifier keys held while clicking

@returnsPromise<void>

rightClick

Promise<void>

Right clicks on the element at the specified coordinates relative to the top-left of it.

@paramrelativeXnumber

Coordinate within the element, along the X-axis at which to click.

@paramrelativeYnumber

Coordinate within the element, along the Y-axis at which to click.

@parammodifiersany

Modifier keys held while clicking

@returnsPromise<void>

focus

Promise<void>

Focus the element.

@returnsPromise<void>

getCssValue

Promise<string>

Get the computed value of the given CSS property for the element.

@parampropertystring
@returnsPromise<string>

hover

Promise<void>

Hovers the mouse over the element.

@returnsPromise<void>

mouseAway

Promise<void>

Moves the mouse away from the element.

@returnsPromise<void>

sendKeys

2 overloads

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.

@paramkeysany[]
@returnsPromise<void>

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.

@parammodifiersModifierKeys
@paramkeysany[]
@returnsPromise<void>

text

Promise<string>

Gets the text from the element.

@paramoptionsany

Options that affect what text is included.

@returnsPromise<string>

setContenteditableValue

Promise<void>

Sets the value of a contenteditable element.

@paramvaluestring

Value to be set on the element.

@returnsPromise<void>

getAttribute

Promise<string | null>

Gets the value for the given attribute from the element.

@paramnamestring
@returnsPromise<string | null>

hasClass

Promise<boolean>

Checks whether the element has the given class.

@paramnamestring
@returnsPromise<boolean>

getDimensions

Promise<ElementDimensions>

Gets the dimensions of the element.

@returnsPromise<ElementDimensions>

getProperty

Promise<T>

Gets the value of a property of an element.

@paramnamestring
@returnsPromise<T>

setInputValue

Promise<void>

Sets the value of a property of an input.

@paramvaluestring
@returnsPromise<void>

selectOptions

Promise<void>

Selects the options at the specified indexes inside of a native select element.

@paramoptionIndexesnumber[]
@returnsPromise<void>

matchesSelector

Promise<boolean>

Checks whether this element matches the given selector.

@paramselectorstring
@returnsPromise<boolean>

isFocused

Promise<boolean>

Checks whether the element is focused.

@returnsPromise<boolean>

dispatchEvent

Promise<void>

Dispatches an event with a particular name.

@paramnamestring

Name of the event to be dispatched.

@paramdataRecord<string, EventData> | undefined
@returnsPromise<void>
Jump to details