Skip to content

Fake newsletter app to show how to write tests with react-native-testing-library

Notifications You must be signed in to change notification settings

MattAgn/NewsletterApp

Repository files navigation

The app

It is a single screen app where you can enter an email to subscribe to a newsletter. If you enter a valid email, you have a success message but if your email is badly formatted, you'll receive an error message. For simplicity's sake, the api used does not really subscribe you to any newsletter, it only checks whether the email given is valid or not.

Architecture of the project

This project contains two different versions of the same app :

  • a basic version: using nothing but internal state and basic components
  • a complex version: using formik, redux and sagas

To switch versions, go to the index and use the App component corresponding to the version you want to use

Install the app

Clone the repo and then, at its root, run yarn or npm i

To run it on ios

Then open up a simulator or connect a real device and run at the root of the project:

cd ios
pod install
cd ..
react-native run-ios

To run it on android

Then open up a simulator or connect a real device and run at the root of the project:

react-native run-android

Tests

Write the first test

Go to this file and follow this article

Run the tests

Just run yarn jest. You can add --coverage to find out how much code the tests cover

About

Fake newsletter app to show how to write tests with react-native-testing-library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published