Posts

Showing posts with the label Enzyme

Testing redux store connected React Components using Jest and Enzyme | TDD | REACT | REACT NATIVE

Image
Hello everyone , in this tutorial we are going to learn at how we can test Redux-Connected components using React / React Native Here is an example of Redux connected component  SlotContainer.js : import React, { Component } from 'react' import { SlotContainerStyles } from '../styles/AppStyle' import Slot from './Slot' import ControlButton from './ControlButton' import {connect} from 'react-redux' import {setUserInteraction,setSlotRunningStatus} from '../../action' import ResultWindow from './ResultWindow' class SlotContainer extends Component { constructor(props) { super (props) this .state = { startSlot : false , } this .timer = null } componentDidMount(){ this .props.setSlotRunningStatus( false ) this .props.setUserInteraction( false ) } updateUserInteraction = (flag) => { } resetSlotMachine = () =>{ } s...

TDD with React Native using Jest and Enzyme using latest versions

Image
By the time I am writing this post, after a lots of search I did not find a unit testing document which will guide me step by step. This article is for my own future reference too. So here are the steps I followed : Start a new react-native project , using command : react-native init  ReactNativeTDDStarterKit This command will create a project for you. Now go to the application path cd    ReactNativeTDDStarterKit Use command react-native run-android , to check whether project is running fine After build is successful you will see build success message. Initially package.json will look like this : { "name": "ReactNativeTDDStarterKit" , "version": "0.0.1" , "private": true , "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start" , "test": "jest" }, "dependencies": { "react": "16.8.3" , ...