<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sanjay Selvaraj</title>
    <description>The latest articles on DEV Community by Sanjay Selvaraj (@sanjayselvaraj).</description>
    <link>https://dev.to/sanjayselvaraj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2655743%2Fd35c6342-93a3-4771-886c-e651ad5f6fa5.jpg</url>
      <title>DEV Community: Sanjay Selvaraj</title>
      <link>https://dev.to/sanjayselvaraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sanjayselvaraj"/>
    <language>en</language>
    <item>
      <title>MSW vs Hosted Mock APIs: When To Use Each</title>
      <dc:creator>Sanjay Selvaraj</dc:creator>
      <pubDate>Sun, 31 May 2026 17:47:16 +0000</pubDate>
      <link>https://dev.to/sanjayselvaraj/msw-vs-hosted-mock-apis-when-to-use-each-3d7</link>
      <guid>https://dev.to/sanjayselvaraj/msw-vs-hosted-mock-apis-when-to-use-each-3d7</guid>
      <description>&lt;p&gt;A few weeks ago I was working on a frontend flow that depended on several backend APIs.&lt;/p&gt;

&lt;p&gt;For local development, MSW was perfect. I could intercept requests, return whatever data I wanted, and keep moving without waiting for backend work.&lt;/p&gt;

&lt;p&gt;The problems started when other people got involved.&lt;/p&gt;

&lt;p&gt;QA wanted to test the same flow.&lt;/p&gt;

&lt;p&gt;A product manager wanted a demo environment.&lt;/p&gt;

&lt;p&gt;We needed a webhook endpoint for an external service.&lt;/p&gt;

&lt;p&gt;Suddenly my local mocks weren't very useful anymore.&lt;/p&gt;

&lt;p&gt;That got me thinking about where local mocking tools end and where hosted mocks start.&lt;/p&gt;

&lt;h2&gt;
  
  
  MSW Is Excellent
&lt;/h2&gt;

&lt;p&gt;I'm not writing this as an MSW critic.&lt;/p&gt;

&lt;p&gt;MSW is probably one of the best developer tools I've used for frontend work.&lt;/p&gt;

&lt;p&gt;A few things it does really well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No backend required&lt;/li&gt;
&lt;li&gt;Works directly in the browser&lt;/li&gt;
&lt;li&gt;Great for component testing&lt;/li&gt;
&lt;li&gt;Great for integration tests&lt;/li&gt;
&lt;li&gt;Easy to simulate different API responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I'm building a React feature and just need to unblock myself, MSW is usually my first choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Local Mocks Start To Struggle
&lt;/h2&gt;

&lt;p&gt;The challenge isn't creating mocks.&lt;/p&gt;

&lt;p&gt;The challenge is sharing them.&lt;/p&gt;

&lt;p&gt;Imagine this setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frontend developer using MSW locally&lt;/li&gt;
&lt;li&gt;QA team testing in a separate environment&lt;/li&gt;
&lt;li&gt;Backend team still building APIs&lt;/li&gt;
&lt;li&gt;Product team reviewing features&lt;/li&gt;
&lt;li&gt;External webhook integrations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now everyone needs access to the same API behavior.&lt;/p&gt;

&lt;p&gt;A mock that only exists on one laptop becomes difficult to coordinate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Hosted Mock APIs Help
&lt;/h2&gt;

&lt;p&gt;Hosted mocks solve a different problem.&lt;/p&gt;

&lt;p&gt;Instead of intercepting requests locally, they expose real HTTPS endpoints.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QA can use them&lt;/li&gt;
&lt;li&gt;Demo environments can use them&lt;/li&gt;
&lt;li&gt;CI pipelines can use them&lt;/li&gt;
&lt;li&gt;Third-party services can send webhooks to them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tradeoff is that you're introducing infrastructure where MSW requires none.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bigger Problem Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;While comparing local and hosted mocks, I kept running into another issue.&lt;/p&gt;

&lt;p&gt;Mocks slowly drift away from reality.&lt;/p&gt;

&lt;p&gt;A field gets removed.&lt;/p&gt;

&lt;p&gt;A type changes.&lt;/p&gt;

&lt;p&gt;The real API evolves.&lt;/p&gt;

&lt;p&gt;Meanwhile the mock keeps returning the old response.&lt;/p&gt;

&lt;p&gt;Tests pass.&lt;/p&gt;

&lt;p&gt;Everything looks fine.&lt;/p&gt;

&lt;p&gt;Until production doesn't.&lt;/p&gt;

&lt;p&gt;Creating mocks turned out to be easy.&lt;/p&gt;

&lt;p&gt;Keeping them trustworthy was the harder problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  So Which Should You Choose?
&lt;/h2&gt;

&lt;p&gt;My rule of thumb is simple.&lt;/p&gt;

&lt;p&gt;Use MSW when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You're developing locally&lt;/li&gt;
&lt;li&gt;You're testing frontend behavior&lt;/li&gt;
&lt;li&gt;You want fast feedback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use hosted mocks when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple people need the same endpoint&lt;/li&gt;
&lt;li&gt;You need public URLs&lt;/li&gt;
&lt;li&gt;You need webhook testing&lt;/li&gt;
&lt;li&gt;You need shared environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, many teams end up using both.&lt;/p&gt;

&lt;p&gt;MSW for local development.&lt;/p&gt;

&lt;p&gt;Hosted mocks for collaboration and integrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;I don't think this is an MSW versus hosted mocks debate.&lt;/p&gt;

&lt;p&gt;They're solving different problems.&lt;/p&gt;

&lt;p&gt;The interesting challenge starts later, when teams have to keep mocks, contracts, and real APIs aligned as systems evolve.&lt;/p&gt;

&lt;p&gt;That's where I've seen the biggest pain points appear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Started Looking Into This
&lt;/h2&gt;

&lt;p&gt;A lot of these observations came from building &lt;a href="https://thodr.com" rel="noopener noreferrer"&gt;Thodr&lt;/a&gt;, a hosted mock API platform for frontend, QA, and integration workflows.&lt;/p&gt;

&lt;p&gt;The original goal was simply to make it easier to create and share mock APIs.&lt;/p&gt;

&lt;p&gt;What surprised me was that creating mocks wasn't the hard problem.&lt;/p&gt;

&lt;p&gt;Keeping mocks aligned with real APIs turned out to be far more challenging, especially as projects, environments, and teams grew.&lt;/p&gt;

&lt;p&gt;That's what led me to start exploring things like contract drift detection and automated validation.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>testing</category>
      <category>opensource</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Sanjay Selvaraj</dc:creator>
      <pubDate>Sun, 31 May 2026 17:40:17 +0000</pubDate>
      <link>https://dev.to/sanjayselvaraj/-2de0</link>
      <guid>https://dev.to/sanjayselvaraj/-2de0</guid>
      <description></description>
    </item>
  </channel>
</rss>
