Skip to main content
Version: 1.2.0

Testing

We are using tests to make sure components keep their functionality between versions and edits. They're many testing libraries for JavaScript and React Native, depending on what type of testing you're doing.

The type of tests we use on React Native Elements are Snapshot and Functional tests.

Snapshot Testing#

Snapshot testing sounds exactly like what it does! It takes snapshot of the structure of a rendered component the props, and their values and saves it. Whenever a change is made it'll compare it to the original snapshot - just to be super sure the change you wanted to make had the desired outcome. If the outcomes is what you expected, then you need to update the snapshot, so that your changes will be the new standard to compare to for changes in the future.

To update the snapshots run this command:

# yarnyarn test -u
# npmnpm run test -u

For Snapshot Testing, we use Jest.

You can read more about snapshot testing here.

Functional Testing#

Functional tests ensures that a component functions the way it should(simplified). This is important for making changes to components, as it makes sure we don't break how something worked previously.

For example:

If a user touches on a button in the button group, then the button selected should be highlightedand the previous one un-highlighted.

For Functional Testing, we use Enzyme.

You can read more about functional testing here.