Testing in React Native — Jest & Detox – Pillow.codes

Testing in React Native  with  Jest & Detox



#ReactJS #Jest

  • Testing can help identify bugs introduced during the development phase of the app and addressing these bugs before release means that your users will always get to use a reliable product.What kind of tests can we use?Unit tests are used to test small modular pieces of code (aka units) independently.Integration tests…
  • One of my favorite things about Jest is a feature called Snapshot testing.Snapshot tests are a very useful tool whenever you want to make sure the UI for a component or the object from an redux action or reducer does not change unexpectedly.Here’s a good explanation of what a snapshot…
  • Here’s a simple example on how to set this up.Jest tests for Pillow Pro appE2E tests: DetoxAn end-to-end test emulates a user by finding and interacting with pieces of UI in your app in a production/release environment.Detox is a gray box E2E Tests and Automation Library for Mobile Apps built by WixWe…
  • Here’s how we handle them in Detox:LoginHere’s a simple example of what a detox test for logging into the app might look like:DemoAnd finally, here’s a part of our E2E test suite in action.
  • Also, automating the tests on Bitrise CI has helped us streamline our release pipeline by preceding every release with the tests workflow.Hopefully, this post details how easy it is to test a React Native app and automate the testing process as well.

At Pillow, we release an update to our Pillow Pro app (iOS & Android) every 2 weeks or so. Most releases are over-the-air (OTA) updates that are done using CodePush, and are fully automated with…
Continue reading “Testing in React Native — Jest & Detox – Pillow.codes”

Jest and the Component Driven Development (CDD) – Comunidad JS – Medium

#Jest and the Component Driven Development (CDD):  #ReactJS #JavaScript

  • Jest and the Component Driven Development (CDD)Testing React and React Native applications.We all knows about TDD right ?
  • I recently discovered other flow/flavor around React Components and Jest snapshot testing that makes me more happy and encourage me to write more tests.This approach makes the dev process a bit more fun that the other way around.
  • Then, when you´re confortable with your component code base and you have applied all the good practices out there, write the actual test, passing the required props to the component being tested and expect it to match the snapshot.Snapshot testingSnapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.The above statement, is from the Jest documentation, and it´s 100% true.
  • I’ve found snapshot testing to be a quick and fun way to test Components and make sure your UI does not change unexpectedly, which is a good thing.The test will fail if the two images do not match: either the change is unexpected, or the screenshot needs to be updated to the new version of the UI component.That means we are not passing the expected props to our component in some parts of our application or we have adjusted the component (because we´ve refactored it).
  • So either one or the other possibility, we need to update the test snapshot (If we´ve refactored it) executing in the terminal yarn test -u or go and fix the part in the application where we´re not using the component as we expect.Having a test coverage between 80 and 100% make us more confidents when we need to deploy to any environment and allows applications to be more robust and easy to scale.In closing, I really encourage React developers to use Jest for testing applications.

We all knows about TDD right ? Test Driven Development.
The philosophy behind it, is to start the development cycle with first writing a failing test and then writing the actual function, to make it…
Continue reading “Jest and the Component Driven Development (CDD) – Comunidad JS – Medium”