Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Latest commit

 

History

History
637 lines (391 loc) · 11.4 KB

modules.md

File metadata and controls

637 lines (391 loc) · 11.4 KB

@pepfar-react-lib/jest-tools / Exports

@pepfar-react-lib/jest-tools

Test utilities for REACT/Jest

Table of contents

Checkbox Functions

Click Functions

Exist Functions

Pause Functions

Radio Functions

Render Functions

Select Functions

Text Functions

Text inside element Functions

Type text Functions

Checkbox Functions

checkboxValue

checkboxValue(id: string, checked: boolean): void

Check that checkbox found by id is checked (or unchecked for false)

example

checkboxValue('includeExpired', true)

Parameters:

Name Type
id string
checked boolean

Returns: void

Defined in: modules/checkbox.utils.ts:12


Click Functions

click

click(id: string): void

Click element found by id

example

click('nextPage')

Parameters:

Name Type
id string

Returns: void

Defined in: modules/click.utils.ts:12


clickByText

clickByText(text: string): void

Click element found by text

example

click('Next page')

Parameters:

Name Type
text string

Returns: void

Defined in: modules/click.utils.ts:25


Exist Functions

exist

Constexist(id: string): null | HTMLElement

Check that element found by id exists in DOM

example

exist('searchBar')

Parameters:

Name Type
id string

Returns: null | HTMLElement

Defined in: modules/exist.utils.ts:12


notExist

ConstnotExist(id: string): void

Check that element with id does not exist in DOM

example

notExist('loading')

Parameters:

Name Type
id string

Returns: void

Defined in: modules/exist.utils.ts:23


Pause Functions

loadingDone

loadingDone(sec?: number): Promise<any>

Wait until loading dialog disappears within sec seconds Assuming loading dialog has id loading

example

await loadingDone(2)

Parameters:

Name Type
sec? number

Returns: Promise<any>

Defined in: modules/pause.utils.ts:28


pause

pause(sec: number): Promise<void>

Pause test execution by sec seconds

example

await pause(0.2)

Parameters:

Name Type
sec number

Returns: Promise<void>

Defined in: modules/pause.utils.ts:12


Radio Functions

checkRadioValue

checkRadioValue(id: string, value: string): void

Check that radio select found by id has selected value value

example

checkRadioValue('method', 'sum')

Parameters:

Name Type
id string
value string

Returns: void

Defined in: modules/radio.utils.ts:12


Render Functions

debug

Letdebug(): void

Show current state of the test DOM enviroment

example

debug()

Returns: void

Defined in: modules/render.utils.ts:16


renderComponent

renderComponent(component: ReactElement, texts: string[]): Promise<any>

Render dynamic component and wait for texts to appear

example

renderComponent(<MainPage/>,['Messages','Friends'])

Parameters:

Name Type
component ReactElement
texts string[]

Returns: Promise<any>

Defined in: modules/render.utils.ts:27


Select Functions

checkSelectValue

checkSelectValue(id: string, value: string): void

Check that select element found by id has value value

example

checkSelectValue('pizzaDough','newYorkSyle')

Parameters:

Name Type
id string
value string

Returns: void

Defined in: modules/select.utils.ts:28


select

select(id: string, value: string): Promise<void>

Select value in select element found by id

example

select('pizzaDough','newYorkSyle')

Parameters:

Name Type
id string
value string

Returns: Promise<void>

Defined in: modules/select.utils.ts:12


Text Functions

noText

noText(text: string): void

Check that text is NOT present in DOM

example

noText('Error')

Parameters:

Name Type
text string

Returns: void

Defined in: modules/text.utils.ts:38


noTexts

noTexts(textsToFind: string[]): void

Check that none of the provided tests are present in dom right now

example

noTexts(['Error','Loading'])

Parameters:

Name Type
textsToFind string[]

Returns: void

Defined in: modules/text.utils.ts:51


text

text(text: string): void

Check if text is present in DOM right now

example

text('My awesome website')

Parameters:

Name Type
text string

Returns: void

Defined in: modules/text.utils.ts:12


textWait

textWait(text: string): Promise<any>

Wait until text appears in DOM

example

await textWait('3 results found')

Parameters:

Name Type
text string

Returns: Promise<any>

Defined in: modules/text.utils.ts:63


texts

texts(texts: string[]): void

Check if multiple texts are present in DOM right now

example

texts(['My website','Login','Latest news'])

Parameters:

Name Type
texts string[]

Returns: void

Defined in: modules/text.utils.ts:25


textsWait

textsWait(textsToFind: string[]): Promise<any>

Wait until all texts appear in DOM

example

await textsWait(['3 results found','George Orwell','1984'])

Parameters:

Name Type
textsToFind string[]

Returns: Promise<any>

Defined in: modules/text.utils.ts:75


Text inside element Functions

noTextIn

noTextIn(id: string, text: string): void

Check that there is no text inside the element found by id

example

noTextIn('results', 'Bob')

Parameters:

Name Type
id string
text string

Returns: void

Defined in: modules/textIn.utils.ts:25


noTextsIn

ConstnoTextsIn(id: string, texts: string[]): void

Check that none of the texts are inside the element found by id

example

noTextsIn('results', ['Bob','Tom'])

Parameters:

Name Type
id string
texts string[]

Returns: void

Defined in: modules/textIn.utils.ts:49


textIn

textIn(id: string, text: string): void

Check if text is present inside of element found by id

example

textIn('username', 'Bob')

Parameters:

Name Type
id string
text string

Returns: void

Defined in: modules/textIn.utils.ts:12


textsIn

ConsttextsIn(id: string, texts: string[]): void

Check that all texts are inside the element found by id

example

textsIn('results', ['Bob','Tom'])

Parameters:

Name Type
id string
texts string[]

Returns: void

Defined in: modules/textIn.utils.ts:38


Type text Functions

type

type(id: string, text: string): void

Type text into input element found by id

example

type('search', 'George Orwell')

Parameters:

Name Type
id string
text string

Returns: void

Defined in: modules/type.utils.ts:13


typeWait

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')

Parameters:

Name Type
id string
text string

Returns: Promise<void>

Defined in: modules/type.utils.ts:26