import {MatFormFieldHarness} from '@angular/material/form-field/testing';
MatFormFieldHarness
Harness for interacting with a standard Material form-field's in tests.
Name | Description |
---|---|
|
async
getAppearance
|
|
---|---|
Gets the appearance of the form-field. |
|
Returns | |
Promise<'legacy' | 'standard' | 'fill' | 'outline'>
|
|
async
getControl
|
|
---|---|
Gets the harness of the control that is bound to the form-field. Only default controls such as "MatInputHarness" and "MatSelectHarness" are supported. |
|
Returns | |
Promise<ControlHarness | null>
|
|
async
getControl
|
|
---|---|
Gets the harness of the control that is bound to the form-field. Searches for a control that matches the specified harness type. |
|
Parameters | |
type ComponentHarnessConstructor<X>
|
|
Returns | |
Promise<X | null>
|
|
async
getControl
|
|
---|---|
Gets the harness of the control that is bound to the form-field. Searches for a control that matches the specified harness predicate. |
|
Parameters | |
type HarnessPredicate<X>
|
|
Returns | |
Promise<X | null>
|
|
async
getLabel
|
|
---|---|
Gets the label of the form-field. |
|
Returns | |
Promise<string | null>
|
|
async
getPrefixText
|
|
---|---|
Gets the text inside the prefix element. |
|
Returns | |
Promise<string>
|
|
async
getSuffixText
|
|
---|---|
Gets the text inside the suffix element. |
|
Returns | |
Promise<string>
|
|
async
getTextErrors
|
|
---|---|
Gets error messages which are currently displayed in the form-field. |
|
Returns | |
Promise<string[]>
|
|
async
getTextHints
|
|
---|---|
Gets hint messages which are currently displayed in the form-field. |
|
Returns | |
Promise<string[]>
|
|
async
getThemeColor
|
|
---|---|
Gets the theme color of the form-field. |
|
Returns | |
Promise<'primary' | 'accent' | 'warn'>
|
|
async
hasErrors
|
|
---|---|
Whether the form-field has errors. |
|
Returns | |
Promise<boolean>
|
|
async
hasLabel
|
|
---|---|
Whether the form-field has a label. |
|
Returns | |
Promise<boolean>
|
|
async
host
|
|
---|---|
Gets a |
|
Returns | |
Promise<TestElement>
|
|
async
isAutofilled
|
|
---|---|
Whether the form-field is currently autofilled. |
|
Returns | |
Promise<boolean>
|
|
async
isControlDirty
|
|
---|---|
Whether the form control is dirty. Returns "null" if no form control is set up. |
|
Returns | |
Promise<boolean | null>
|
|
async
isControlPending
|
|
---|---|
Whether the form control is pending validation. Returns "null" if no form control is set up. |
|
Returns | |
Promise<boolean | null>
|
|
async
isControlTouched
|
|
---|---|
Whether the form control has been touched. Returns "null" if no form control is set up. |
|
Returns | |
Promise<boolean | null>
|
|
async
isControlValid
|
|
---|---|
Whether the form control is valid. Returns "null" if no form control is set up. |
|
Returns | |
Promise<boolean | null>
|
|
async
isDisabled
|
|
---|---|
Whether the form-field is disabled. |
|
Returns | |
Promise<boolean>
|
|
async
isLabelFloating
|
|
---|---|
Whether the label is currently floating. |
|
Returns | |
Promise<boolean>
|
|
static
with
|
|
---|---|
Gets a |
|
Parameters | |
options FormFieldHarnessFilters = {}
|
|
Returns | |
HarnessPredicate<MatFormFieldHarness>
|
a |
Deprecated
async
getHarnessLoaderForPrefix
|
|
---|---|
Gets a reference to the container element which contains all projected prefixes of the form-field. |
|
Returns | |
Promise<TestElement | null>
|
|
Deprecated
async
getHarnessLoaderForSuffix
|
|
---|---|
Gets a reference to the container element which contains all projected suffixes of the form-field. |
|
Returns | |
Promise<TestElement | null>
|
|
FormFieldHarnessFilters
A set of criteria that can be used to filter a list of MatFormFieldHarness
instances.
Name | Description |
---|---|
|
Filters based on the text of the form field's floating label. |
|
Filters based on whether the form field has error messages. |
FormFieldControlHarness
Possible harnesses of controls which can be bound to a form-field.
type FormFieldControlHarness = MatInputHarness | MatSelectHarness | MatDatepickerInputHarness | MatDateRangeInputHarness;