@pepfar-react-lib/jest-tools / Exports
Test utilities for REACT
/Jest
▸ checkboxValue(id
: string, checked
: boolean): void
Check that checkbox found by id
is checked
(or unchecked for false
)
example
checkboxValue('includeExpired', true)
Name | Type |
---|---|
id |
string |
checked |
boolean |
Returns: void
Defined in: modules/checkbox.utils.ts:12
▸ click(id
: string): void
Click element found by id
example
click('nextPage')
Name | Type |
---|---|
id |
string |
Returns: void
Defined in: modules/click.utils.ts:12
▸ clickByText(text
: string): void
Click element found by text
example
click('Next page')
Name | Type |
---|---|
text |
string |
Returns: void
Defined in: modules/click.utils.ts:25
▸ Const
exist(id
: string): null | HTMLElement
Check that element found by id
exists in DOM
example
exist('searchBar')
Name | Type |
---|---|
id |
string |
Returns: null | HTMLElement
Defined in: modules/exist.utils.ts:12
▸ Const
notExist(id
: string): void
Check that element with id
does not exist in DOM
example
notExist('loading')
Name | Type |
---|---|
id |
string |
Returns: void
Defined in: modules/exist.utils.ts:23
▸ loadingDone(sec?
: number): Promise<any>
Wait until loading dialog disappears within sec
seconds
Assuming loading dialog has id loading
example
await loadingDone(2)
Name | Type |
---|---|
sec? |
number |
Returns: Promise<any>
Defined in: modules/pause.utils.ts:28
▸ pause(sec
: number): Promise<void>
Pause test execution by sec
seconds
example
await pause(0.2)
Name | Type |
---|---|
sec |
number |
Returns: Promise<void>
Defined in: modules/pause.utils.ts:12
▸ checkRadioValue(id
: string, value
: string): void
Check that radio select found by id
has selected value value
example
checkRadioValue('method', 'sum')
Name | Type |
---|---|
id |
string |
value |
string |
Returns: void
Defined in: modules/radio.utils.ts:12
▸ Let
debug(): void
Show current state of the test DOM enviroment
example
debug()
Returns: void
Defined in: modules/render.utils.ts:16
▸ renderComponent(component
: ReactElement, texts
: string[]): Promise<any>
Render dynamic component and wait for texts
to appear
example
renderComponent(<MainPage/>,['Messages','Friends'])
Name | Type |
---|---|
component |
ReactElement |
texts |
string[] |
Returns: Promise<any>
Defined in: modules/render.utils.ts:27
▸ checkSelectValue(id
: string, value
: string): void
Check that select element found by id
has value value
example
checkSelectValue('pizzaDough','newYorkSyle')
Name | Type |
---|---|
id |
string |
value |
string |
Returns: void
Defined in: modules/select.utils.ts:28
▸ select(id
: string, value
: string): Promise<void>
Select value
in select element found by id
example
select('pizzaDough','newYorkSyle')
Name | Type |
---|---|
id |
string |
value |
string |
Returns: Promise<void>
Defined in: modules/select.utils.ts:12
▸ noText(text
: string): void
Check that text
is NOT present in DOM
example
noText('Error')
Name | Type |
---|---|
text |
string |
Returns: void
Defined in: modules/text.utils.ts:38
▸ noTexts(textsToFind
: string[]): void
Check that none of the provided tests are present in dom right now
example
noTexts(['Error','Loading'])
Name | Type |
---|---|
textsToFind |
string[] |
Returns: void
Defined in: modules/text.utils.ts:51
▸ text(text
: string): void
Check if text
is present in DOM right now
example
text('My awesome website')
Name | Type |
---|---|
text |
string |
Returns: void
Defined in: modules/text.utils.ts:12
▸ textWait(text
: string): Promise<any>
Wait until text
appears in DOM
example
await textWait('3 results found')
Name | Type |
---|---|
text |
string |
Returns: Promise<any>
Defined in: modules/text.utils.ts:63
▸ texts(texts
: string[]): void
Check if multiple texts
are present in DOM right now
example
texts(['My website','Login','Latest news'])
Name | Type |
---|---|
texts |
string[] |
Returns: void
Defined in: modules/text.utils.ts:25
▸ textsWait(textsToFind
: string[]): Promise<any>
Wait until all texts appear in DOM
example
await textsWait(['3 results found','George Orwell','1984'])
Name | Type |
---|---|
textsToFind |
string[] |
Returns: Promise<any>
Defined in: modules/text.utils.ts:75
▸ noTextIn(id
: string, text
: string): void
Check that there is no text
inside the element found by id
example
noTextIn('results', 'Bob')
Name | Type |
---|---|
id |
string |
text |
string |
Returns: void
Defined in: modules/textIn.utils.ts:25
▸ Const
noTextsIn(id
: string, texts
: string[]): void
Check that none of the texts
are inside the element found by id
example
noTextsIn('results', ['Bob','Tom'])
Name | Type |
---|---|
id |
string |
texts |
string[] |
Returns: void
Defined in: modules/textIn.utils.ts:49
▸ textIn(id
: string, text
: string): void
Check if text
is present inside of element found by id
example
textIn('username', 'Bob')
Name | Type |
---|---|
id |
string |
text |
string |
Returns: void
Defined in: modules/textIn.utils.ts:12
▸ Const
textsIn(id
: string, texts
: string[]): void
Check that all texts
are inside the element found by id
example
textsIn('results', ['Bob','Tom'])
Name | Type |
---|---|
id |
string |
texts |
string[] |
Returns: void
Defined in: modules/textIn.utils.ts:38
▸ type(id
: string, text
: string): void
Type text
into input
element found by id
example
type('search', 'George Orwell')
Name | Type |
---|---|
id |
string |
text |
string |
Returns: void
Defined in: modules/type.utils.ts:13
▸ typeWait(id
: string, text
: string): Promise<void>
Type text
into input
element found by id
and then wait to allow DOM to reflect changes
example
await typeWait('search', 'George Orwell')
Name | Type |
---|---|
id |
string |
text |
string |
Returns: Promise<void>
Defined in: modules/type.utils.ts:26