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”

Guest Post: Automatically Deploy Pull Requests for Create React Native App and Expo Projects

  • TL;DR;appr builds and deploys pull requests in your create-react-native-app and Expo-based projects, and posts a link and a QR code to your PR, so you can run the app on your device or emulator in seconds!Great teams review their codeI’m sure you’ll agree: Code reviews are a useful tool in a development team’s workflow.
  • You wouldn’t release code to production without having another pair of eyes on it first, would you?Thankfully, GitHub makes code reviews simple.
  • Netlify offers the same functionality for deploying static front end sites.Sadly, this one-click workflow hasn’t been available to mobile developers without setting up complex build and deployment pipelines, and even then, installing an app to be able to test a simple change still takes way too long.Inspired by Expo Sketch, I wanted to see if it would be possible to set up review apps for React Native.Introducing apprAppr is a script that deploys pull requests in your project to Expo, and posts a link and a QR code to your PR.
  • Point your Expo app camera to the QR code and the review app will launch on your device.
  • Switching to your preferred CI should be easy, and PRs to add support are welcome!To make testing your pull requests easy, head to FormidableLabs/appr on GitHub and follow the simple Getting started guide to add appr to your project!

Jani builds React Native apps at Formidable, a Seattle/London-based consultancy and open-source shop. You can follow him on Twitter as @jevakallio. appr builds and deploys pull requests in your…
Continue reading “Guest Post: Automatically Deploy Pull Requests for Create React Native App and Expo Projects”