jest enzyme test unit component How do you mock a react component with Jest? We got a component which is included another external components **InstallCom** and **UserCom** ( github ): import { } from 'installComponent'import from 'userComponent' InstallCom UserCom export class ShareCom extends Component {render() {return (<div>< para1='title1'/>< para2='title2' /></div>)}} InstallCom UserCom Unit Test In unit test, what we care about is the functionality of <ShareCom />, but not other dependent components , for mock purpose , is a good helper. **InstallCom** and **UserCom** jest import {ShareCom} from '../somewhere/ShareCom' ('../somewhere/UserCom', () => ()=> <div id="mockUserCom">mockUserCom</div>) jest.mock ('installComponent', () => ({InstallCom: 'mockInstallCom'})) jest.mock describe('ShareCom', () => {it('should return correct component', () => {const wrapper = mount(<ShareComsomething={something}/>) expect(wrapper.find('mockInstallCom').length).toEqual(1) expect(wrapper.find('#mockUserCom').length).toEqual(1) })}) Reference: — Git: https://gist.github.com/wahengchang/108ca55981f6600c252ad0cb9d4c518f