<?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 Tejendra Patel on Medium]]></title>
        <description><![CDATA[Stories by Tejendra Patel on Medium]]></description>
        <link>https://medium.com/@t3j3ndra?source=rss-776963ada243------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ldWAoeG_vspoehiLRD7JYA.jpeg</url>
            <title>Stories by Tejendra Patel on Medium</title>
            <link>https://medium.com/@t3j3ndra?source=rss-776963ada243------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:49:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@t3j3ndra/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[How to contribute to open source community]]></title>
            <link>https://medium.com/@t3j3ndra/how-to-contribute-to-open-source-community-12cb66b0de39?source=rss-776963ada243------2</link>
            <guid isPermaLink="false">https://medium.com/p/12cb66b0de39</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Tejendra Patel]]></dc:creator>
            <pubDate>Sun, 09 Jun 2024 16:34:18 GMT</pubDate>
            <atom:updated>2024-06-09T16:34:18.264Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous post, I talked about leaving JS World Conference inspired to contribute to the open source community. During a Q&amp;A with some members of the React founding team, I asked Dan Abramov for his suggestions on how developers can contribute to open source.</p><p>Three simple ways to contribute:</p><ol><li>Verify if issues are actual bugs. Try to reproduce open issues and determine if it’s a bug. If it is, try to create a reproducible sandbox or leave detailed instructions on how to reproduce the bug. This will save the maintainers lot of time and can instead focus on fixing the issue.</li><li>Not all contributions need to be code commits. Read through the documentation and help improve the README and the documentations.</li><li>The community ecosystem projects need some TLC too. Find smaller, less known projects that you can contribute to. Trying to contribute to React or Vue or another larger project is very difficult for someone new.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12cb66b0de39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lessons from attending a tech conference in a different country]]></title>
            <link>https://medium.com/@t3j3ndra/lessons-from-attending-a-tech-conference-in-a-different-country-1df8dd160f8d?source=rss-776963ada243------2</link>
            <guid isPermaLink="false">https://medium.com/p/1df8dd160f8d</guid>
            <category><![CDATA[reflections]]></category>
            <category><![CDATA[developer-life]]></category>
            <category><![CDATA[lessons-learned]]></category>
            <dc:creator><![CDATA[Tejendra Patel]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 20:18:26 GMT</pubDate>
            <atom:updated>2023-02-16T20:48:59.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="JS World Conference" src="https://cdn-images-1.medium.com/max/1024/1*JLtgHtcdOOUI5ObyAfhk8g.jpeg" /></figure><p>I went to Amsterdam to attend the JS World Conference. Given that this was my first conference in five years, there were a number of takeaways that I was able to draw from the experience.</p><ol><li><strong>Attend conferences that are not directly related to what you do day to day to get exposure of where the industry is at.</strong> At work, we use the same technologies and get knee deep in them. It becomes difficult to carve out time to keep up with where the trend is going and get your hands dirty with new technologies on a side project. As a result, we fall behind, unaware of whats happening outside of work. During a Q&amp;A with some members of the React founding team, someone had mentioned how while they were at Facebook, they never looked outside the walls of Facebook. They were using tools and technologies build within Facebook. When he left, he wasn’t aware of Amazon AWS. This conference was Vue focused and helped me see outside of the React ecosystem. We should aim to be a versatile developer who can learn and solve problems regardless the framework.</li><li><strong>Not every talk will be interesting to you, but as long as you can walk away inspired and pick up a thing or two, it’s a win.</strong> The <a href="https://www.youtube.com/watch?v=8pDqJVdNa44">React documentary</a> by Honeypot was premiered at the conference and Dan Abramov was there. Watching that documentary, I got inspired to get involved with the open source community and be a contributor. During Q&amp;A, I asked Dan for his advice on how to get started giving back to the open source community. I will create another article on how to contribute to open source and share Dan’s suggestions. One of my favorite talk was by a developer, <a href="https://joehart.co.uk/">Joe Hart</a>, who inspired me to learn about the limitations and possibilities of the tools we use everyday by doing something the tool was expressly not designed for. He had implemented Age of Empire 2 using React. From that experience, he learned about how the React render loop works compared to how a render loop works in games. It was a great reminder to have fun with code. Doing these silly throw away projects really help you learn the technologies you are working with.</li><li><strong>Learning to talk to strangers!</strong> It is very nerve-racking to talk to strangers. What will I talk about, what am I trying to get out of the conversations, should I talk to vendors knowing that I’m never going to buy what they are selling? You never know who you might bump into and where the conversation might go. At a bare minimum, talk to other attendees and introduce yourself and ask them what their favorite talk has been so far. And if the conversation feels comfortable, move away from work related talk and ask what’s the best experience they had so far in the area the conference is being hosted. If you’ve never been to this place before, you might just find some great recommendations from a local. And if things go really well, you might form a friendship. Talk to every vendor to ask them for a demo of what they do and you might get free swag as a reward! The advice I just mentioned is easy to give, hard to do. I know because I didn’t talk to a single attendee. In retrospect, this is what I learned and what I will do at my next conference.</li><li><strong>Great way to meet your remote co-workers! </strong>Even though you are busy all day at the conference, you get to bond with your co-workers in a way you can’t in the office. For us, it was almost like a mini vacation. We went out for dinner, went to a karaoke place, took a tour of the city and found a hidden speakeasy bar. We formed a better bond then the trust building games the consultants have you play during team off sites. There might be a big age gap between your coworkers or have really big differences in interests, but just see that as an opportunity for you to try something new, different and outside your comfort zone.</li><li><strong>Traveling isn’t only about having time and money, but also about having the courage to travel.</strong> This was my first time traveling outside the United States and India, so going to Amsterdam was really exciting. I had my hotel booked, Google Maps to help me navigate, and a credit card to pay for whatever I needed. But I was uncomfortable with the unknown of traveling solo in a foreign country. I understood that traveling isn’t only about having time and money, but also about having the courage to travel.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1df8dd160f8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to clear RTK Query cache in tests between requests when using Mock Service Worker and Jest?]]></title>
            <link>https://medium.com/@t3j3ndra/how-to-clear-rtk-query-cache-in-tests-between-requests-when-using-mock-service-worker-and-jest-cb36ea4ffb4b?source=rss-776963ada243------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb36ea4ffb4b</guid>
            <category><![CDATA[redux-toolkit]]></category>
            <category><![CDATA[mock-service-worker]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-testing-library]]></category>
            <dc:creator><![CDATA[Tejendra Patel]]></dc:creator>
            <pubDate>Thu, 30 Sep 2021 16:40:34 GMT</pubDate>
            <atom:updated>2021-09-30T16:42:43.328Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setup</h3><p>I’m using Redux Toolkit and RTK Query in my create-react-app project and writing tests using React Testing Library with MSW for mocking.</p><h3>The Problem</h3><p>I wrote these three tests using msw to mock the API response. Test 1 would pass but Test 2 and 3 would fail. If I skipped Test 1, then Test 2 and 3 would pass. I didn’t understand why.</p><pre>// Test 1<br>test(&#39;renders items from API on page load&#39;, async () =&gt; {<br>  // mock API response defined by default msw handler, returns an array of items<br>  // render component and assert<br>});<br></pre><pre>// Test 2<br>test(&#39;renders error message if API fails&#39;, async () =&gt; {<br>  // override the API response for this endpoint in this test<br>  server.use(<br>    rest.get(&#39;/items&#39;, (req, res, ctx) =&gt;<br>      res(<br>        ctx.status(500), <br>        ctx.json({ message: &#39;Internal Server Error&#39; })<br>      )<br>    )<br>  );</pre><pre>// render component and assert</pre><pre>});</pre><pre><br>// Test 3<br>test(&#39;renders no items message if API returns 0 items&#39;, async () =&gt; {<br>  // override the API response for this endpoint in this test<br>  server.use(<br>    rest.get(&#39;/items&#39;, (req, res, ctx) =&gt; <br>      res(ctx.json([]))<br>    )<br>  );<br>  <br>  // render component and assert</pre><pre>});</pre><h3>The Root Cause</h3><blockquote><a href="https://redux-toolkit.js.org/rtk-query/usage/cache-behavior">A key feature of RTK Query is its management of cached data. When data is fetched from the server, RTK Query will store the data in the Redux store as a ‘cache’. When an additional request is performed for the same data, RTK Query will provide the existing cached data rather than sending an additional request to the server</a>.</blockquote><p>By default RTK Query will cache each API endpoint definition. In my case, RTK Query will create a cache for <strong>/items </strong>and always return the same data. Mock service worker was returning the data I mocked out, however, RTK Query was ignoring the data from msw and returning data from the cache.</p><p>To verify msw was returning my mocked response, I used the <a href="https://github.com/visionmedia/debug#readme">debug</a> package to inspect.</p><pre>yarn add debug --dev<br>DEBUG=* yarn test</pre><p>I was able to verify msw was adding the runtime request handler defined in my tests using server.use.</p><h3>The Solution</h3><p>After each test, the API state needs to be reset. When a API is created using RTK Query createApi function, the API has a util function, util.resetApiState(), that can be called to clear the cache.</p><p>According to the <a href="https://github.com/reduxjs/redux-toolkit/blob/2ff1fa4364ce0dfa82dbbd3187aa0c63e57d5582/packages/toolkit/src/query/core/module.ts#L209">docs</a>, <strong>dispatch(api.util.resetApiState())</strong> will:</p><blockquote>A Redux action creator that can be dispatched to manually reset the api state completely. This will immediately remove all existing cache entries, and all queries will be considered ‘uninitialized’</blockquote><p>In setupTests.js, define the beforeAll(), afterEach(), and afterAll() functions and inside the afterEach fn, call <strong>store.dispatch(myApi.util.resetApiState());</strong></p><p>See the gist below for more details.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/065311e4468d335b757d5269bc1a7118/href">https://medium.com/media/065311e4468d335b757d5269bc1a7118/href</a></iframe><h3>Reference</h3><ul><li><a href="https://stackoverflow.com/questions/67999073/how-to-clear-rtk-query-cache-in-tests-between-requests-when-using-msw-and-jest">Stack Overflow question</a></li><li><a href="https://mswjs.io/docs/getting-started/install">Mock Service Worker</a></li><li><a href="https://redux-toolkit.js.org/rtk-query/usage/cache-behavior">RTK Query</a></li><li><a href="https://gist.github.com/tejendra/12cc775750ae156dad4d48b2e6d2538b">My gist for source code</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb36ea4ffb4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>