Testing · React Native - Deepstash
Testing in React Native

As your codebase expands, small errors and edge cases you don’t expect can cascade into larger failures. Bugs lead to bad user experience and ultimately, business losses. One way to prevent fragile...

4

STASHED IN:

7

Testing · React Native

reactnative.dev

STASHED IN:

0 Comments

The default template of React Native ships with Jest testing framework. It includes a preset that's tailored to this environment so ...

STASHED IN:

7

Structuring Tests

Your tests should be short and ideally test only one thing.

The test in the image is described by the string passed to the

1

STASHED IN:

7

Jest offers describe function to help structure your tests. Use describe to group together all t...

STASHED IN:

7

Unit tests

Unit tests cover the smallest parts of code, like individual functions or classes.

The great thing about unit tests is that they are quick to write and run. Therefore, as you work, you get fa...

STASHED IN:

7

Sometimes, when your tested objects have external dependencies, you’ll want to “mock them out.” “Mocking” is when you replace some dependency of your code with your own implementa...

STASHED IN:

7

In integration testing, real individual units are combined (same as in your app) and tested together to ensure that their cooperation works as expected. This is not to say that moc...

STASHED IN:

7

For testing React components, there are two things you may want to test:

  • Interaction: to ensure the component behaves correctly when interacted with by a user (eg. when user pre...

STASHED IN:

7

Component Tests

There are several libraries that can help you testing these:

STASHED IN:

7

Avoid testing implementation details like props or state—while such tests work, they are not oriented toward how users will interact with the component and tend to break by refactoring (for example...

STASHED IN:

7

Snapshot testing is an advanced kind of testing enabled by Jest.

A "component snapshot" is a textual representation of ...

STASHED IN:

7

End-to-End Tests

In end-to-end (E2E) tests, you verify your app is working as expected on a device (or a simulator / emulator) from the user perspective.

This is done by building your app in ...

STASHED IN:

7

Deepstash helps you become inspired, wiser and productive, through bite-sized ideas from the best articles, books and videos out there.

GET THE APP: