<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hungry Hub (AppServation Co., Ltd) on Medium]]></title>
        <description><![CDATA[Stories by Hungry Hub (AppServation Co., Ltd) on Medium]]></description>
        <link>https://medium.com/@hungryhub-org?source=rss-2e38fd1da264------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4jXEkDc-P60Gorlbo_O2lQ.png</url>
            <title>Stories by Hungry Hub (AppServation Co., Ltd) on Medium</title>
            <link>https://medium.com/@hungryhub-org?source=rss-2e38fd1da264------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:18:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hungryhub-org/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mock your unnecessary module in Jest]]></title>
            <link>https://medium.com/hungryhub-tech/mock-your-unnecessary-module-in-jest-82f09f153433?source=rss-2e38fd1da264------2</link>
            <guid isPermaLink="false">https://medium.com/p/82f09f153433</guid>
            <category><![CDATA[jest]]></category>
            <dc:creator><![CDATA[Hungry Hub (AppServation Co., Ltd)]]></dc:creator>
            <pubDate>Wed, 20 Jan 2021 10:42:10 GMT</pubDate>
            <atom:updated>2021-01-20T10:42:10.066Z</atom:updated>
            <content:encoded><![CDATA[<p>When doing testing, we want to mock a module that has nothing to do with our business logic (example: modoule which functions to send an error report). Let’s say we have fetchUser.js to get some user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r4nZLyoEY1qDmc5g.png" /><figcaption>fetchUser.js</figcaption></figure><p>In that module, we call myAjax.js module that bassically doing http request to API server and send error report using rollbar when something wrong happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tqZByrJjKdl8zm8e.png" /><figcaption>myAjax.js</figcaption></figure><p>When we testing fetchUser.js we just want testing business logic and dont care abaout error reporting. Because in getJson() function that we called in fetchUser.js using Rollbar module we must mock that module first. To do that we create __mocks__ folder beside rollbar module location and create file that have same name (rollbar.js)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/0*xiPWLLJ2LwNSHlUj.png" /><figcaption>folder structure</figcaption></figure><p>Next in,our test file we can mock rollbar module like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*140-LAP9Dt2lItCZ.png" /><figcaption>fetchUser.spec.js</figcaption></figure><p>All done, we can focus to test our business logic</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82f09f153433" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hungryhub-tech/mock-your-unnecessary-module-in-jest-82f09f153433">Mock your unnecessary module in Jest</a> was originally published in <a href="https://medium.com/hungryhub-tech">HungryHub-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>