Categories
Mastering Development

How to test react navigation authentication flow?

I’m developing a React Native application. I’m doing something like what’s explained here to implement the authentication flow. So, I created an AppContainer that looks like this: import {createAppContainer, createSwitchNavigator, createStackNavigator} from “react-navigation”; import AuthLoadingScreen from “../screens/auth/auth-loading-screen”; const AppStack = createStackNavigator({ Home: {screen: HomeScreen} }); const AuthStack = createStackNavigator({ SignIn: {screen: SignInScreen} }); const AppContainer […]

Categories
Development

jest failing with “Target container is not a DOM element.” cause it tests my index.tsx

So i want to set up testing on a react project i working on. i set up some test files, but jest always fails with Test suite failed to run Target container is not a DOM element. 4 | import App from ‘~/App’; 5 | > 6 | ReactDOM.render(<App />, document.getElementById(‘root’)); | ^ 7 | […]

Categories
Development

“Navbar refers to a value, but is being used as a type here” when trying to render a shallow copy of my component when testing

I am trying to write a test to my React component, using TypeScript, Jest as my test runner and Enzyme for testing my React components. Whenever I pass my component into the shallow Enzyme function, I get the ts error “‘Navbar’ refers to a value, but is being used as a type here.”, and underneath […]

Categories
Database Development Facebook Social Media

SQLite database getting initialized on every app restart

Below is my code that I am working on. App.js /** * Sample React Native App * https://github.com/facebook/react-native * * Generated with the TypeScript template * https://github.com/react-native-community/react-native-template-typescript * * @format */ import * as React from ‘react’; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from ‘react-native’; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, […]