victorkvarghese / react-native-boilerplate

🚀 Type Based Architecture for developing React Native Apps using react, redux, sagas and hooks with auth flow
MIT License
600 stars 209 forks source link

How to write test cases ? #15

Closed bhaveshpatel1 closed 4 years ago

bhaveshpatel1 commented 4 years ago

Can you please provide one example for write testcases for login page? I have written below test case for login page but it not executes. Can you please help me on that ?

import React from 'react'; import Enzyme, { mount } from 'Enzyme'; import EnzymeAdapter from 'enzyme-adapter-react-16'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; import reducer from '../app/reducers/loginReducer'; import Login from '../app/src/crust/containers/Login'

Enzyme.configure({ adapter: new EnzymeAdapter() });

describe(' test', () => { const mockStore = createStore(reducer, {count: 0}); const getWrapper = () => mount(

);

it('should add to count and display the correct # of counts', () => { const wrapper = getWrapper(); expect(wrapper.find('Text').text()).toEqual('Count: 0'); wrapper.find('Button').simulate('onPress'); expect(wrapper.find('Text').text()).toEqual('Count: 1'); }); });

victorkvarghese commented 4 years ago

@bhaveshpatel1 I will try to add test cases in future. I'm not sure whether you are saying that you are not bale to write one or execute the test case. To run test you can use yarn test