المشاريع
عرض على GitHub
vanGalilea/react-native-testing
حول
إليك الطريقة الموصى بها لاختبار مكوّنات React Native باستخدام Jest وReact Native Testing Library.
تطوير الويب والتطبيقاتالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- -١
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصل
No More Hacks and Headaches <> Learn How to Test Your Components Before Your Users Will
Covered Examples 🎞
- 👆 Clicking buttons and asserting onPress' outcome.
- 📲 Filling a simple login form and asserting successful submission.
- 🎣 Custom hook testing (number of alternatives).
- 📡 Mocking fetch calls.
- 🧭 Navigating through screens with React Navigation.
- 🚟 Navigating through screens with Expo Router.
- 🔚 E2E feel due to real navigation throughout screens.
- 📥 Handling and mocking providers.
- 📹 Mocking external lib.'s components.
- 🎭 Mocking and interacting with RN's Modal component.
- 🧾 Handling with a screen with RN's FlatList component.
- 📡 Using MSW to mock api calls and handling loading/errors.
Tools in use 🛠️
Setup and requirements 📋
Getting Started 🚀
- Clone the repo
git clone [email protected]:vanGalilea/react-native-testing.git - Run
yarnto install dependencies - Explore RN CLI app and/or Expo app's tests and source code that are relevant to your use case.
RN CLI application
How to run the tests 🏃♀️
- Run
cd apps/rn-cli-appto navigate to the app folder - Run
yarn test:unitto run the unit tests - Run
yarn test:unit:devto run the unit tests in dev/watch mode - Run
yarn test:unit:coverageto run the tests and generate a coverage report
Make sure you have built and run the app in dev mode before running the e2e tests.
- Run
yarn test:e2eto run the e2e tests - Run
yarn test:e2e:devto run the e2e tests in dev/watch mode - Run
yarn test:e2e:recordto run the e2e tests and record a video of the tests
How to run the app 📱
- Run
cd apps/rn-cli-appto navigate to the app folder - Run
npx pod-installto install iOS dependencies - Run
yarn startto start the metro bundler - Click
ito run the app on iOS simulator orato run it on Android emulator
Expo application
How to run the tests 🏃♀️
- Run
cd apps/rn-expo-appto navigate to the app folder - Run
yarn test:unitto run the unit tests
How to run the app 📱
- Run
cd apps/rn-expo-appto navigate to the app folder - Run
yarn startto start the metro bundler - Click
ito run the app on iOS simulator orato run it on Android emulator
Inspiration, resources and further reading 📚
- 📑 A blog by Steve Galili on "Where and How to Start Testing Your React Native App"
- 👏 Inspired by Kent C. Dodds' workshop Test React Components with Jest and React Testing Library. For more info check Epic React.
- 📕 React Native Testing Library
- 🧑🔬️ Jest
- ️⚛️ React Native
- 🗺 React Navigation
- 🛰 MSW
Impression of the project 📸
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…