Raixa, a simple and customizable way to write React Test Library unit tests
Raixa is pronounced "Raisha" and is in reference to a 13th century country mansion in Spain.
Quickstart
1. Import Raixa at the top of your test file
import Raixa from 'raixa';
2. Render your component
Raixa.render(
<UserCard
name="Divardo"
age={10}
/>
);
3. Use Raixa functions for all assertions, interactions etc.
Example:
Raixa.click('#UserCard-change-profile-button');
Raixa.typeInto('#UserCard-new-name-field', 'Calicci');
...
Raixa Functions:
Interactions – interact with stuff on the page
- click - click something
- clickByContents - click something (find it by its contents)
- typeInto - type text into an element
Intelligent Waiting – wait better
- waitFor - wait for a set amount of time
- waitForElementAbsent - wait until an element is absent
- waitForElementPresent - wait until an element is present (on the page even if offscreen)
- waitForElementWithContentsPresent - wait for ane element with specific contents to be present (on the page even if offscreen)
- waitForElementWithContentsVisible - wait for an element with specific contents to be visible (on the page and visible)
Assertions – make sure your app behaves properly
- assertAbsent - make sure an element is absent
- assertAbsentWithContents - make sure an element is absent (find it by its contents)
- assertExists - make sure an element exists
- assertExistsWithContents - make sure an element exists (find it by its contents)
- assertDoesNotHaveClass - make sure an element does not have a certain css class
- assertHasClass - make sure an element has a certain css class
- assertNumElements - make sure an element shows up a certain number of times
Handy Functions – useful utilities
- uniquify - add a unique, random tag to a string