damgad
damgad

Reputation: 1446

How to do automatic, on device tests for react native application?

I want to create automatic tests for an application written in react native. I want to test only logic (not the UI).

Jest seems to be great solution for unit or even integration tests which will be run on a computer. But I would like to test the application on a real device. I have a component without UI that does some logic, wireless communication with other devices etc. I need to test that communication especially, which cannot be done without a device.

Are there any frameworks or standard solutions to do such thing?

Upvotes: 2

Views: 1266

Answers (1)

damgad
damgad

Reputation: 1446

Ok, I did my research about testing react native applications.

At the moment ReactNative doesn't provide a platform independent test framework that could run integration (not UI) tests on real device. In fact there is a RCTTestRunner but it's functionality is limited and it works only for iOS devices.

Functional tests

There are multiple functional test frameworks. These tests mainly depend on UI components and are used for black-box testing of user interactions. There are two mature cross platform frameworks that could be used for that: Calabash and Appium. Appium seems to be better solution as it's a single tool for both platforms (Calabash is actually set of two projects for iOS and Android). Also Appium supports multiple languages (JavaScript, Python, Java, ...) when Calabash supports only Ruby.

There is also a Cavy project that looks promising but uses React ref generating functions in a hacky way and needs multiple modifications in the application code.

But all of that is intended to do only UI testing.

Workaroud solution

The solution which I used to test logic of the application (without being influenced by UI changes) is following. I created special version of the application (by creating new target) which have replaced the main UI component with test one. That test component runs on the top of the application. It is just triggering tests and displaying the logs. These logs are then read and parsed by functional test framework to produce the report.

Upvotes: 2

Related Questions