One of the advantages of having a custom design system and component library is that we don't start from scratch when writing tests that target an application using it. We know very precicesly what shape the structure the DOM will take, and we can use that knowledge to our advantage when it comes to writing tests.
For most components in the stripes-components library, there is a corresponding interactor that can be used in your tests. For example, to interact with a stripes Button in a Jest test, you would do something like the following:
import { Button, Heading } from '@folio/stripes-testing';
import { App } from '../app';
describe('My Page', () => {
beforeEach(() => render(<App>));
it('can click a button to reveal a secret message', async () => {
await Button('Click Me!').click();
await Heading('Thank You!').exists();
});
})
You can use these interactors inside any testing framework that runs in the same runtime environment as the DOM such as Karma, Jest, Cypress, or BigTest Platform. However, they cannot be used with test runners that runs tests in a remote runtime environment that does not include the DOM under test such as Selenium, or Nightmare.
See the general guide for working with interactors for more information
The simplest answer to this question is that in the vast majority of cases, you should not need to write your own interactors for your application.
One of the goals of the @folio/stripes-testing
library is that if your
application is built with stripes components, then the ability to
simulate any user interaction is baked in for free. Even though your
application is built out of many complex components, your user still
interacts directly with the low-level input components like
"button", "textfield".
Sometimes there are interactions that span many different components
that need to be captured so that they can be used multiple times in
multiple test cases. In this instance, you might be tempted to make a
custom interactor to encapsulate this process. However, consider using
a simple async
function instead that itself uses interactors under
the hood to manipulate the actual components:
export async function Login(username, password) {
await TextField('username').fillIn(useranme);
await TextField({ placeholder: 'password' }).fillIn(password);
}
you can now use this function anywhere inside your test code:
beforeEach(Login('abfab', 'absolutely-fabulous'));
If an async
function won't do, and you think that what's called for
is an interactor, then you might have found a gap in the
@stripes/testing
library itself. In that case, you can follow the
guide for creating a custom
interactor
and make a pull request to this package.
Accordion
AutoSuggest
Avatar
Badge
Button
ButtonGroup
Checkbox
Dropdown
Datepicker
(Calendar Widget
)IconButton
KeyValue
Layer
List
(ListItem
)MultiColumnList
(MultiColumnListCell
)MultiSelect
(`MultiSelectOption)NavList
Pane
(PaneHeader
)RadioButton
RichTextEditor
SearchField
Select
Selection
TextArea
TextField
Tooltip
The accordion element
import { Accordion } from '@folio/stripes-testing';
Accordion('Location').is({ open: true });
Accordions are identified by their header. For example:
Accordion('Categories').exists();
clickHeader()
: clicks on an accordion to either open or close itfocus
: transfers focus to the open/close toggle of this accordion
id
: string = the DOM element id of this accordion. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuelabel
: string = the user identifying text of this accordion. This is the same value as the locator.open
: boolean =true
if this accordion is expanded,false
, if notfocused
: boolean =true
if the keyboard focus is anywhere inside this accordionindex
: number = the 0 based index of this accordion with in a pane set. So for exampleAccordion('Users').has({ index: 2 })
would assert that the "Users" accordion was 3rd in its accordion set.
Renders a fieldgroup of common address form fields.
Related: AddressEdit, AddressView
import { AddressList } from '@folio/stripes-testing';
// expand collapsed address list
AddressList().toggleMore();
// add address to address list...
AddressList().addAddress();
// assert that Address list displays 2 addresses
AddressList().has({ count: 3 });
toggleMore
: clicks the expansionsclickEdit
: number - clicks the edit button at the given indexaddAddress
: clicks the add button, exposes a new address formdeleteAddress
: number - deletes the address at a given index
count: number of visible address views in the list
import { AddressEdit } from '@folio/stripes-testing';
// find address form at index 1
AddressEdit({ index: 1 });
// find address form with validation errors
AddressEdit({ error: true });
// save the values (click the save button on the address form)
AddressEdit().save();
save
- Clicks the save buttoncancel
- Clicks the cancel buttondelete
- Clicks the delete button
index
: number - filters by index.error
: boolean - whether or not the form contains an error.
Type-ahead suggestion list component using a text field.
// find via visible label
AutoSuggest('country').exists();
// fill in value to the field
AutoSuggest.fillIn('blue');
Located via the visible label text.
open
: boolean =true
if the avatar is rendering its fallback svg graphic.selected
: string = filter by the selected option from the suggestion list.value
: string = filter/assert by the value of the text input.
fillIn
: string = focuses, fills, blurs the text field.enterFilter
: string = focuses, and fills the text field with a string (opens suggestion list).select
: string = clicks the suggestion labeled with the provided string.
Avatar component used for displaying a profile picture.
// interact with a single Avatar instance...
Avatar().exists();
// interact with an avatar instance containing image with filename containing 'pic'
Avatar(including('pic')).exists();
A specific avatar can be located via the image filename, via including
or matches
.
placeholder
: boolean =true
if the avatar is rendering its fallback svg graphic.image
: boolean =true
if the avatar is rendering an<img>
tag.
Renders a circular icon with small text content (a number/count).
Locate via the containing text ('1').
// interact with a single Badge instance...
Badge().exists();
// badge containing the number 2...
Badge('2');
// assert value....
Badge.has({ value: 2 });
Locate via the text content/number within the badge.
color
: string = one ofprimary
,red
,default
- use withincluding
ormatches
value
: string = text rendered within the badge.
The Button element
import { Button } from '@folio/stripes-testing';
Button('Click Me').click();
Buttons are located by their text content. For example:
Button('Click Me').has({ text: 'Click Me' });
click()
: clicks the button
id
: string = the DOM element id of this button. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuetext
: string = the text content of the button. This is the same value as the locator.href
: string = thehref
of the button, if providedbutton
: boolean =true
if the button is a<button>
button elementanchor
: boolean =true
if the button is a<a>
anchor elementdefault
: boolean =true
if the button contains thedefault
classariaLabel
: string = the button'sariaLabel
attributevisible
: boolean =true
if the button is visiblefocused
: boolean =true
if the button is in-focus
Component used for styling a set of buttons.
// click the button with the label 'holdings'
ButtonGroup().click('holdings');
buttonCount
: number = number of child buttons in buttonGroup.
click
: string = click the child button with the provided label.
User notification component. Informs on success/failure of actions within the system.
Callout('There was a problem').exists();
// check type of callout
Callout.has({ type: calloutType.error });
id
: string = the id of the callout element.type
: string = one of 'success', 'error', 'info', 'warning' - different callout types that set corresponding styles to the callout.
dismiss
: clicks the dismiss (X) button in the callout.
Card is a presentational component representing a box of related information.
Card().exists();
// card with certain text exists...
Card('Card content text').exists();
headerStart
: string= text contained in 'header start' element of the card.headerEnd
: string= text contained in the 'header end' element of the card.style
: string= style of the card. One of 'default' 'positive' 'negative'
The checkbox element
import { checkbox } from '@folio/stripes-testing';
Checkbox('Label').is({ checked: true });
A checkbox is identified by the label. For example:
Checkbox('Label').exists();
click
: clicks on checkbox label to toggle the checked statusfocus
: transfers focus to the enclosing label of this checkboxclickInput
: clicks on the actual checkbox (helpful if there is no label)clickAndBlur
: clicking also focuses the checkbox, this will immediately blur after the click which will trigger the field validation
id
: string = the DOM element id of this checkbox. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuetitle
: string = the element titlelabel
: string = the user identifying text of this checkbox. This is the same value as the locator.checked
: boolean =true
if this checkbox is expanded,false
, if notvalid
: boolean =true
is validvalue
: string = the checkbox value if definedfocused
: boolean =true
if the keyboard focus is anywhere inside this checkboxariaLabel
: boolean = the aria label as passed via the propsariaInvalid
: boolean =true
is rendered with'true'
, otherwise falsefeedbackText
: string = the text related to the validation warning or errorhasWarning
: boolean =true
if the checkbox has a warning [class]hasError
: boolean =true
if the checkbox has an error [class]
The datepicker and related elements
import { Datepicker } from '@folio/stripes-testing';
Datepicker().has({ today: true, required: true });
Datepickers can be identified by their label. For example:
Datepicker('Start Date').is({ visible: true });
openCalendar
: clicks the icon that opens the calendar widgetclear
: removes the value from the fieldclick
: clicks the fieldfocusInput
: focuses the inputfillIn(value: string)
: fill in a specific date value as if the user typed in the fieldfocus
: focuses the input fieldblur
: blurs the input field
id
: string = the DOM element id of this datepciker. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuelabel
: string = the user identifying text of this datepicker. This is the same value as the locator.placeholder
: string = the input placeholder which is a user identifying text if label is not sufficiently unique.focused
: boolean =true
if the keyboard focus targets the inputwarning
: boolean =true
if in a warning stateerror
: boolean =true
if in an error stateinputValue
: string = the value in inputinputDay
: number = the day that is in the inputtoday
: boolean =true
if the date in the input is today's dateempty
: boolean =true
if the date in the input is clearedvisible
: boolean =true
if the input is visibledisabled
: boolean =true
if the input is disabledreadOnly
: boolean =true
if the input is set to read onlyrequired
: boolean =true
if the input is a required field
import { Calendar } from '@folio/stripes-testing';
Calendar().is({ visible: true });
The calendar widget does not have a locator. Only one widget may be visible at a time.
click
: clicks on the calendar widget containerfocus
: focuses on the calendar widget containerclickDay(value: string)
: clicks the day passed on the calendar widgetfocusDay(value: string)
: focuses on a day passed within the calendar widgetsetYear(value: string)
: sets the year passed within the year input field in the widget
today
: boolean =true
if the input today's datemonth
: string = the currently selected monthyear
: string = the currently selected yeardays
: [string, string, ...] = an array of strings representing all of the days present (and not excluded) as two digits,03
for the third day of the month. Note that days which are shown that are not within the currently selected month are surrounded by underscores, e.g._31_
,_01_
excludedDays
: [string, string, ...] = the inverse ofdays
, an array of strings representing all of the dates that are excludedportal
: boolean =true
if the widget is created within the#OverlayContainer
portalvisible
: boolean =true
if the input is visiblefocused
: boolean =true
if the calendar widget container is focusedfocusedWithin
: boolean =true
if anything within the widget has focus
The Stripes Dropdown component
import { Dropdown } from '@folio/stripes-testing';
Dropdown('Menu').choose('Contact Us');
Dropdowns are identified by their label, or trigger
Dropdown('Menu').exists();
choose(optionName: string)
: clicks a given option in the dropdown
open
: boolean =true
if the dropdown is openvisible
: boolean =true
if the dropdown is visiblelabel
: string = the user identifying text of this dropdown. This is the same value as the locator.
Editable table component.
import { EditableList, ColumnHeader, TextField } from '@folio/stripes-testing';
// Assert that a particular column is present
EditableList().find(ColumnHeader('name')).exists();
// Assert that editing is disabled on rows
EditableList().has({ editDisabled: true });
// Fill in a value...
EditableListRow()
.find(TextField(including('name')))
.fillIn('test');
rowCount
: number the number of rows in the table (includes editable rows)addDisabled
: boolean Whether or not the add button is disablededitDisabled
: boolean Whether or not the row-level edit buttons are disableddeleteDisabled
: boolean Whether or not the row-level delete buttons are disabledaddButton
: boolean Whether or not the Add button is present.editButtons
: boolean Whether or not the Edit buttons are present.deleteButtons
: boolean Whether or not the Delete buttons are present.
add
: clicks the add button, addint an item to the list.
For use within the Editable list...
// Fill in a value...
EditableListRow().find(TextField(including('name'))).fillIn('test');
index
: number the number of the row - 0-based. Defaults to 0.saveDisabled
: boolean Whether or not the save button is disabled.
edit
: clicks the edit button on a non-edit row, activating edit mode.delete
: clicks the delete button on a non-edit row.cancel
: clicks the cancel button on a row in edit mode.save
: clicks the save button on a row in edit mode.
Creates a hierarchical navigation view with links, detail pages and edit forms. Includes additional interactors for EntryForm and EntryDetails. Additional tests and assertions can also be performed using the Button and Link interactors.
import { EntryManager, EntryDetails, EntryForm } from '@folio/stripes-testing';
// Click the link with the 'Central Office' text
EntryManager().navTo('Central Office');
// Assert that the Entry Detail page is present.
EntryDetails(including('Central Office')).exists();
// click the save button on an EntryForm
EntryForm('Central Office').save();
- navTo: string clicks the link in the EntryManager's navigation list with the supplied text.
- createEntry: clicks the button to create a new entry.
- save: clicks the EntryForm's 'save' button.
The IconButton element
import { IconButton } from '@folio/stripes-testing';
IconButton('Close').click();
An IconButton is located by its aria-label. For example:
IconButton('Close').has({ ariaLabel: 'Close' });
focus()
: sets focus on the icon buttonclick()
: clicks the icon button
id
: string = the DOM element id of this icon button. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuehref
: string = thehref
of the icon button, if providedhash
: string = thehash
of the icon button, if providedbutton
: boolean =true
if the icon button is a<button>
button elementanchor
: boolean =true
if the icon button is a<a>
anchor elementariaLabel
: string = the button'sariaLabel
attributefocused
: boolean =true
if the button is in-focus
Key Value are simple label/text pairs.
import { KeyValue } from '@folio/stripes-testing';
KeyValue('Occupation').has({ value: 'librarian' });
KeyValue pairs are identified by their key. E.g.
KeyValue('Occupation').exists();
value
: string = The value associated with the keysubValue
: string = KeyValue components can have a subvalue which is a slightly less emphasized
The layer element
import { Layer } from '@folio/stripes-testing';
Layer('layer label').is({ visible: true });
Layers are hidden initially and more structural in nature. As such, they can be identified by visual context. This is not applicable to screen readers however so the component requires an aria-label to suit. For example:
Layer('layer label').exists();
None.
id
: string = the DOM element id of this layer. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valueariaLabel
: string = the user identifying text of this layer. This is the same value as the locator.visible
: boolean = the state of the layer's visibility. Note that with the initial state of this element, it does not exist in the DOM, and it will be unable to find an element with{ visible: false }
.focused
: boolean =true
if the keyboard focus is anywhere inside this layer
The list element
import { List } from '@folio/stripes-testing';
List('list-id').is({ count: 10 });
The List is able to be located by the id
due the structural nature of the element.
List('list-id').exists();
None.
count
: number = the number of items in the List, counting from 0, e.g.Array.length
import { ListItem } from '@folio/stripes-testing';
ListItem('list-id').has({ index: 10 });
The ListItem is located by the text content.
ListItem('Jane Doe').exists();
click()
: clicks the list item
index
: number = find an item within a list based on the index
The MultiColumnList element contains two interactors: an interactor for the overall container, MultiColumnList
, and an interactor that let's you target specific cells, MultiColumnListCell
.
import { MultiColumnList } from '@folio/stripes-testing';
MultiColumnList().is({ visible: true });
The MultiColumnList is able to be located by the id
due the structural nature of the element.
MultiColumnList('mcl-container').exists();
Alternatively when only one is rendered on the page, you will likely prefer to omit the locator.
MultiColumnList().exists();
clickHeader
: clicks on the overall header elementscrollBy({direction: string, value: int})
: scrolls the container in selected direction by the specified pixels entered as a value, will trigger the related scroll eventsclick({row: int, column: string})
: clicks a cell within the MCL with the specified to row and column. Both row and column default to the cell in the first row and first column
id
: string = the DOM element id of this layer. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuecolumns
: [string, string, ...] = an array of strings representing each column header textheaderInteractivity
: [boolean, boolean, ...] = an array of boolean representing if each column header is clickablecolumnCount
: number = the number of columns in the MCLrowCount
: number = the number of rows in the MCL, counting from 0, e.g.Array.length
height
: number = the container height, e.g.el.offsetHeight
width
: number = the container width, e.g.el.offsetWidth
visible
: boolean =true
if the button is visible
import { MultiColumnListCell } from '@folio/stripes-testing';
MultiColumnListCell('Jane Doe').is({ content: true });
The MultiColumnListCell is located by the text content.
MultiColumnListCell('Jane Doe').is({ selected: true });
click
: clicks on the cell
content
: string = the content within a cellrow
: number = find a cell within a row based on the indexcolumn
: string = find a cell within a column, preferred overcolumnIndex
columnIndex
: number = find a cell within a column based on the index, prefer use ofcolumn
as that is user facingselected
: boolean =true
if the cell is selectedmeasured
: boolean = if the width of the cell has been measured
The MultiSelect element with autocompletion
import { MultiSelect } from '@folio/stripes-testing';
MultiSelect('Tags').select(['important', 'urgent']);
The MultiSelect is located by the label.
MultiSelect('Tags');
open
: opens the menu with all available valuesfillIn(string)
: filters values for selection by substringselect(string[])
: selects multiple values from a menu
selected
: string[] = the current selected values
Renders a list of links or buttons.
import { NavList } from '@folio/stripes-testing';
Navlist().has({ id: 'myNavListId' });
// assert that NavList contains 5 items
Navlist().has({ count: 5 });
count
: number -number of links in the list
navTo
: string -clicks a link the link with the supplied string.
The pane element
import { Pane } from '@folio/stripes-testing';
Pane('Search Result').is({ visible: true });
Panes are identified by their title. For example:
Pane('Search Result').exists();
dismiss
: clicks on close button on the selected panefocus
: focuses the paneblurs
: blurs (removes focus of) the pane
id
: string = the DOM element id of this pane. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuetitle
: string = the user identifying text of this pane. This is the same value as the locator.subtitle
: string = an additional user identifying text if needed to differentiate between panes.focused
: boolean =true
if the keyboard focus is anywhere inside this paneindex
: number = the 0 based index of this pane with in a pane set. So for examplePane('Users').has({ index: 2 })
would assert that the "Users" pane was 3rd in its pane set.
The header element of Pane
import { PaneHeader } from '@folio/stripes-testing';
PaneHeader('EBSCO').is({ visible: true });
Headers are identified by their title. For example:
Pane('EBSCO').exists();
The RadioButton element
import { RadioButton } from '@folio/stripes-testing';
RadioButton('Label').is({ checked: true });
A RadioButton is identified by the label. For example:
RadioButton('Label').exists();
click
: clicks on RadioButton label to toggle the checked statusfocus
: transfers focus to the RadioButton inputblur
: blurs (removes focus of) the RadioButton
id
: string = the DOM element id of this radio button. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuetitle
: string = the element titlelabel
: string = the user identifying text of this radio button. This is the same value as the locator.checked
: boolean =true
if this radio button is checked,false
, if notvalid
: boolean =true
if the radio button is validvalue
: string = the radio button value if definedfocused
: boolean =true
if the keyboard focus is anywhere inside this radio buttonariaLabel
: boolean = the aria label as passed via the propsariaInvalid
: boolean =true
is rendered with'true'
, otherwise falsefeedbackText
: string = the text related to the validation warning or errorhasWarning
: boolean =true
if the radio button has a warning [class]hasError
: boolean =true
if the radio button has an error [class]
Wrapper component for set of RadioButton components.
RadioButtonGroup('Label').exists();
// set an option (labeled 'Blue') in a RadioButtonGroup
RadioButtonGroup('Label').choose('Blue');
RadioButtonGroups are primarily selected from their label
prop (rendered as a <legend>
)
id
: string = Dom element id of RadioButtonGroupoption
: string = interact with the corresponding labeled option within the RadioButtonGroupcheckedOption
: string = interact with given option (label), if checkedfeedbackText
: string = interact/assert against error text.
choose
: string = chooses option at corresponding label.focus
: string = focuses the radio button at the corresponding label.blur
: blurs the focus from the currently focused radio button.
Field component for list of objects containing the same fields/properties. Users can add or remove individual items.
// a RepeatableField can be located via its level/legend
const rf = RepeatableField('Modes of Issuance').exists();
// assert against the item count
rf.has({ itemCount: 2 });
// click the add button
rf.clickAddButton();
// since item fields can vary, an item can be filled in via a function...
const fillFields = (interactor) => {
interactor.find(TextField('name')).fillIn('Thomas');
interactor.find(Select('honorific')).chooseAndBlur('Mr');
};
rf.fillItem({ index: 1, fillFn: fillFields });
A RepeatableField can be located via its level/legend innerText.
id
: string = Dom element id of the RepeatableField's fieldset.emptyMessage
: string = the empty message of the repeatable field, if present.removeButton
: boolean = whether or not the delete button is presentaddButton
: boolean = whether or not the add button is presentaddDisabled
: boolean = whether or not the add button is disabled.remvoeDisabled
: boolean = whether or not the remove button(s) is/are disabled.itemCount
: number = filter/assert against an item count.headLabels
: boolean = head labels present.
clickAddButton
: clicks the add button, adding a blank item.clickRemoveButton
: number = clicks the remove button on an item at the supplied index.fillItem
:index
-number,fillFn
-function = fills fields within an item via thefillFn
function - use additional interactors for fields.
The Rich text editor component
import { RichTextEditor } from '@folio/stripes-testing';
RichTextEditor('Body').has({ text: 'Note body' });
A RichTextEditor is identified by the label. For example:
RichTextEditor('Body').exists();
- `fillIn(string): fills in the editor with a given value
value
: string = the current value of the editor
Stripes SearchField component for initiating queries
import { SearchField } from '@folio/stripes-testing';
SearchField().has({ id: 'searchFieldTest' });
A SearchField is located by ___. For example:
SearchField('Label').exists();
selectIndex(string)
: selects the searchable index to perform this search on. For example "users" or "locations"fillIn(value: string)
: fills in the text field with a given value
id
: string = the DOM element id of the containedselect
element. Note that this not the id of the React component. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing value.placeholder
: string = The placeholder text of the containedinput
element.value
: string = thevalue
property of the containedinput
element.readOnly
: boolean =true
if the containedinput
is read-only.disabled
: boolean =true
if the containedinput
is disabled.
Stripes Select component wraps a basic <select>
tag, but also has
other features to integrate it with forms, including things like error
states, etc..
import { Select } from '@folio/stripes-testing';
Select('Currency').choose('USD');
Selects are identified by their label
Select('Country').exists();
choose(optionName: string)
: selects the option matching option name
id
: string = the DOM element id of the actual htmlselect
element. Note that this not the id of the React component. Theid
filter is provided for debugging, but should not generally be used in tests since it is not a user-facing valuelabel
: string = the user identifying text of this select. This is the same value as the locator.placeholder
: string = The placeholder text of the containedselect
elementvalue
: string = thevalue
property of the select element. It will be the currently selected optionerror
: string = text of the error associated with thisselect
. If there is no error, then this will be undefinedwarning
: string = text of the warning associated with this select. If there is no warning, then this will be undefinedvalid
: boolean = is this select valid?
Stripes-components Select substitute with filterable options list.
Selection components are located via their label.
id
: string = DOM element id of the button which the user interacts with.value
: string = the inner text of the button, set as the value of the component.error
: string = text of the error associated with this control.warning
: string = text of the warning associated with this control.open
: boolean = whether or not the options list is open.focused
: boolean = whether or not the control is in focus.
toggle
: open/close the options list.filterOptions
: string = conditionally open the list (if closed) and enter a string into the filter field.choose
: string = conditionally open the options list and choose an item corresponding to the provided label.focus
: focuses the control.
Stripes TextArea component wraps a standard textarea
element,
adding support for things like controls and error states.
import { TextArea } from '@folio/stripes-testing';
TextArea('leave a comment').exists();
A TextArea is located by its label property:
TextArea('leave a comment').has({ text: 'leave a comment' });
id
: string = the DOM element id of this textarea. Theid
filter is provided for debugging, but should not generally be used for testslabel
: string = the label of the textareavalue
: string = the current value of the textareaerror
: string = text of the error associated with this textarea. If there is no error, then this will be undefinedwarning
: string = text of the warning associated with this textarea. If there is no warning, then this will be undefinedvalid
: boolean = is this textarea valid?
blur()
: removes focus from the textareafillIn(value: string)
: fills in the textarea with a given valuefocus()
: sets focus on the textarea
Stripes TextField component wraps a standard input
text element, adding support for things like controls and error states.
import { TextField } from '@folio/stripes-testing';
TextField('First Name').exists();
Text fields are located by their label or by the aria-label
attribute overwise:
TextField('First Name').has({ label: 'First Name' });
id
: string = the DOM element id of this text field. Theid
filter is providerd for debugging, but should not generally be used for testslabel
: string = the label of the text fieldtype
: string = the type of the text field. should always return'text'
value
: string = the current value of the text fieldfocused
: boolean =true
if the text field is currently in focusreadOnly
: boolean =true
if the text field is read-onlystartControl
: string = the text content of thestartControl
elementendControl
: string = the text content of theendControl
elementerror
: string = text of the error associated with this text field. If there is no error, then this will be undefinedwarning
: string = text of the warning associated with this text field. If there is no warning, then this will be undefinedvalid
: boolean = is this text field valid?
blur()
: removes focus from the text fieldclear()
: clears the text field's current valuefillIn(value: string)
: fills in the text field with a given valuefocus()
: sets focus on the text field
Informational text that appears next to an element on mouseover in order to provide additional instructions
import { Tooltip } from '@folio/stripes-testing';
Tooltip('Throw this user to the trash').exists();
Tooltips are located by their text property:
Tooltip('save this document').has({ text: 'save this document' });
id
: string = the DOM element id of this tooltip. Theid
filter is providerd for debugging, but should not generally be used for teststext
: string = the text of the toolipsubtext
: string = subtext of the tooltipvisible
: boolean =true
if the tooltip is currently showingproximity
: boolean =true
if this tooltip is a proximity tooltip in the DOM for the benefit of assitive technology. You should not generally need to use this filter in tests