<?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: qinjie xu</title>
    <description>The latest articles on DEV Community by qinjie xu (@qinjiexu2).</description>
    <link>https://dev.to/qinjiexu2</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4124282%2F360ee4a7-77ab-4fc8-a292-611de12bf966.png</url>
      <title>DEV Community: qinjie xu</title>
      <link>https://dev.to/qinjiexu2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/qinjiexu2"/>
    <language>en</language>
    <item>
      <title>A ZIP code is not a number. Please stop treating it like one.</title>
      <dc:creator>qinjie xu</dc:creator>
      <pubDate>Wed, 25 Nov 2026 15:13:11 +0000</pubDate>
      <link>https://dev.to/qinjiexu2/a-zip-code-is-not-a-number-please-stop-treating-it-like-one-38ll</link>
      <guid>https://dev.to/qinjiexu2/a-zip-code-is-not-a-number-please-stop-treating-it-like-one-38ll</guid>
      <description>&lt;h1&gt;
  
  
  A ZIP code is not a number. Please stop treating it like one.
&lt;/h1&gt;

&lt;p&gt;A ZIP code looks like a number. It is five digits, people read it aloud as a number, and every spreadsheet program on earth will happily turn it into one. That is exactly why it breaks things.&lt;/p&gt;

&lt;p&gt;The moment a ZIP code becomes an integer, every ZIP beginning with zero loses its leading zero. &lt;code&gt;02108&lt;/code&gt; becomes &lt;code&gt;2108&lt;/code&gt;. &lt;code&gt;01234&lt;/code&gt; becomes &lt;code&gt;1234&lt;/code&gt;. The value is no longer a ZIP code — it is a different number that happens to be four digits long.&lt;/p&gt;

&lt;p&gt;This is not a hypothetical. It is one of the most common data corruption bugs in address handling, and it happens at every layer: CSV imports, spreadsheet exports, JSON serializers, form validators that call &lt;code&gt;parseInt&lt;/code&gt;, database columns typed as &lt;code&gt;INT&lt;/code&gt;, and analytics pipelines that "clean" the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the zero disappears
&lt;/h2&gt;

&lt;p&gt;Here are the places I have seen it happen in real systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spreadsheets.&lt;/strong&gt; Open a CSV with a ZIP column in Excel or Sheets. It auto-detects a number and drops the leading zero. Save and re-export; the data is gone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript validators.&lt;/strong&gt; &lt;code&gt;parseInt("02108", 10)&lt;/code&gt; returns &lt;code&gt;2108&lt;/code&gt;. A validator that checks &lt;code&gt;zip.length === 5&lt;/code&gt; after parsing will reject a valid Boston ZIP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database schema.&lt;/strong&gt; An &lt;code&gt;INT&lt;/code&gt; column cannot store &lt;code&gt;02108&lt;/code&gt;. It stores &lt;code&gt;2108&lt;/code&gt;. The application may format it back to five digits with padding, but the source of truth is already wrong, and any system that reads the column directly gets the broken value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API payloads.&lt;/strong&gt; A backend that types the ZIP field as &lt;code&gt;number&lt;/code&gt; in its schema will serialize &lt;code&gt;02108&lt;/code&gt; as &lt;code&gt;2108&lt;/code&gt;. The frontend receives a corrupted value and has no way to know it was ever different.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pattern is always the same: something decides the field is numeric because it &lt;em&gt;looks&lt;/em&gt; numeric, and the type conversion quietly destroys information.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule is simple
&lt;/h2&gt;

&lt;p&gt;A ZIP code is an identifier, not a quantity. You never add two ZIP codes together, you never compute an average ZIP, and no ZIP is "larger" than another in any meaningful sense. Identifiers are strings. Store them as strings, validate them as strings, transmit them as strings.&lt;/p&gt;

&lt;p&gt;In JavaScript, validate the shape without converting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;isValidUSZip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;/^&lt;/span&gt;\&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;\&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a database, use &lt;code&gt;VARCHAR(5)&lt;/code&gt; or &lt;code&gt;VARCHAR(10)&lt;/code&gt; if you support ZIP+4. In a JSON schema, use &lt;code&gt;"type": "string"&lt;/code&gt; with a pattern. In a CSV, quote the field so spreadsheet software treats it as text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this survives into production
&lt;/h2&gt;

&lt;p&gt;Because most test data starts with a ZIP like &lt;code&gt;12345&lt;/code&gt; or &lt;code&gt;90210&lt;/code&gt; — values that do not begin with zero. Every test passes. The happy path is clean. The bug waits for a customer in Massachusetts, New Jersey, or anywhere else in the Northeast, and their checkout fails for a reason nobody can see from the logs.&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://addresslab.net" rel="noopener noreferrer"&gt;AddressLab&lt;/a&gt; partly to make this class of bug impossible to miss. It is a free, no-sign-up generator for US address test data, and its samples deliberately include ZIPs that begin with zero. You can generate a batch, export the selected fields as CSV or JSON, and check the file into your repo as a fixture. Now the leading-zero case runs in CI on every commit instead of showing up in a support ticket.&lt;/p&gt;

&lt;p&gt;The generated addresses are for development, testing, education, and prototypes — not real delivery. The email field is a format placeholder for validation and storage testing, not a mailbox. Those limits are the point: a fixture should be obviously disposable.&lt;/p&gt;

&lt;h2&gt;
  
  
  A quick checklist
&lt;/h2&gt;

&lt;p&gt;If you want to find this bug in your own stack, check four places:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The form input — is it &lt;code&gt;type="text"&lt;/code&gt; with &lt;code&gt;inputmode="numeric"&lt;/code&gt;, or did someone use &lt;code&gt;type="number"&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;The validator — does it parse the value before checking its shape?&lt;/li&gt;
&lt;li&gt;The database column — is the ZIP typed as &lt;code&gt;INT&lt;/code&gt; anywhere?&lt;/li&gt;
&lt;li&gt;The export path — does the CSV quote the ZIP field so a spreadsheet will not eat the zero?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Four checks, five minutes. Considerably cheaper than explaining to a customer why their address was rejected.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>api</category>
      <category>datascience</category>
    </item>
    <item>
      <title>The fixture is the feature: generating address test data that actually breaks forms</title>
      <dc:creator>qinjie xu</dc:creator>
      <pubDate>Wed, 25 Nov 2026 14:30:38 +0000</pubDate>
      <link>https://dev.to/qinjiexu2/the-fixture-is-the-feature-generating-address-test-data-that-actually-breaks-forms-2o8n</link>
      <guid>https://dev.to/qinjiexu2/the-fixture-is-the-feature-generating-address-test-data-that-actually-breaks-forms-2o8n</guid>
      <description>&lt;h1&gt;
  
  
  The fixture is the feature: generating address test data that actually breaks forms
&lt;/h1&gt;

&lt;p&gt;Most address forms are tested with one record: &lt;code&gt;John Doe, 123 Main St, Springfield, 12345&lt;/code&gt;. That record is a gift to the implementation. It has no unit number, the ZIP is unremarkable, the name fits every field, and the state is probably the first option in the dropdown. The form passes, the demo works, and the first real customer with an apartment number finds the bug for you.&lt;/p&gt;

&lt;p&gt;I spent a while building a generator for exactly this problem. &lt;a href="https://addresslab.net" rel="noopener noreferrer"&gt;AddressLab&lt;/a&gt; produces free, no-sign-up US address samples for development and QA — state, ZIP, phone, email, and a formatted full address field, plus multi-country formats and tax-free state addresses. But the interesting part was not generation. It was deciding what makes a fixture &lt;em&gt;useful&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A good fixture is annoying on purpose
&lt;/h2&gt;

&lt;p&gt;If your test data looks like the happy path, it only tests the happy path. The records worth keeping are the ones that make you uncomfortable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leading-zero ZIP prefixes.&lt;/strong&gt; Anything beginning with 0 is a great way to find a validator that silently coerces strings to integers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unit and apartment numbers.&lt;/strong&gt; "Apt 4B", "Suite 200", "#12" — three different human conventions that a single &lt;code&gt;street&lt;/code&gt; field has to survive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Names that do not fit the template.&lt;/strong&gt; Hyphens, apostrophes, a family name longer than the input's maxlength.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-US formats.&lt;/strong&gt; If the product claims international support, generate a non-US address and see whether the "country" dropdown is the only thing that actually supports it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these are edge cases in the real world. They are the normal shape of a normal address. Which is why shipping a form that rejects them is so common.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generation is cheap; reproducibility is the point
&lt;/h2&gt;

&lt;p&gt;Anyone can generate one address. The valuable thing is getting a hundred into the shape your test harness expects, then keeping them forever.&lt;/p&gt;

&lt;p&gt;AddressLab lets you save generated records locally and export the selected fields as CSV or JSON. That means you generate once, check the file into the repo, and now every CI run exercises the same awkward cases. Six months later, when someone "simplifies" the ZIP validator, the regression test fails on the same input that broke it the first time.&lt;/p&gt;

&lt;p&gt;Without a stored fixture, that regression is discovered by a customer. With one, it is discovered by a build.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two boundaries worth stating out loud
&lt;/h2&gt;

&lt;p&gt;The tool has deliberate limits, and hiding them would make it worse:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generated addresses are for development, testing, education, and prototypes. They are not real identities and will not receive mail.&lt;/li&gt;
&lt;li&gt;The generated email is a format placeholder for validation, storage, display, and export testing. It cannot receive messages. If you need to test delivery, use a mailbox your QA team controls.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those limits matter because a fixture that &lt;em&gt;looks&lt;/em&gt; deliverable is exactly how a prototype gets mistaken for production data. A test address should be obviously disposable.&lt;/p&gt;

&lt;h2&gt;
  
  
  A workflow that has held up
&lt;/h2&gt;

&lt;p&gt;Here is the sequence I now use for any new address form:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the actual validation rules first — minimum length, allowed characters, ZIP format, whether state is a dropdown or free text.&lt;/li&gt;
&lt;li&gt;Generate a batch that deliberately covers the edges listed above.&lt;/li&gt;
&lt;li&gt;Export to CSV, drop it into the fixtures folder, and run the form against every row.&lt;/li&gt;
&lt;li&gt;Leave about five percent headroom on any field with a hard downstream limit, so normalization and trimming do not turn a passing fixture into a false alarm.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is unglamorous work. It is also the difference between a form that passed a demo and a form that survives contact with actual users.&lt;/p&gt;

&lt;p&gt;If you have ever watched a checkout reject a perfectly valid "Apt 4B", you already know why this category of tool exists.&lt;/p&gt;

</description>
      <category>devtools</category>
      <category>testing</category>
    </item>
    <item>
      <title>Compressing images in the browser with Canvas (and hitting an exact KB target)</title>
      <dc:creator>qinjie xu</dc:creator>
      <pubDate>Thu, 29 Oct 2026 13:15:00 +0000</pubDate>
      <link>https://dev.to/qinjiexu2/compressing-images-in-the-browser-with-canvas-and-hitting-an-exact-kb-target-40af</link>
      <guid>https://dev.to/qinjiexu2/compressing-images-in-the-browser-with-canvas-and-hitting-an-exact-kb-target-40af</guid>
      <description>&lt;p&gt;Every "compress image" feature I've shipped has followed the same arc: upload the file, compress it on the server, send it back. It works, but it means you're paying for bandwidth twice, storing other people's photos, and adding a round trip to something that should feel instant.&lt;/p&gt;

&lt;p&gt;Modern browsers can do the whole job locally. Here's what I learned building it, including the part that took the longest — hitting a &lt;em&gt;specific&lt;/em&gt; file size instead of just "smaller".&lt;/p&gt;

&lt;h2&gt;
  
  
  The baseline: &lt;code&gt;toBlob&lt;/code&gt; with a quality knob
&lt;/h2&gt;

&lt;p&gt;The core is two lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bitmap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createImageBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OffscreenCanvas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drawImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;convertToBlob&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;image/jpeg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;quality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things worth knowing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use &lt;code&gt;createImageBitmap&lt;/code&gt; over &lt;code&gt;new Image()&lt;/code&gt;.&lt;/strong&gt; It decodes off the main thread, and by default it applies EXIF orientation (&lt;code&gt;imageOrientation: "from-image"&lt;/code&gt;), so phone photos don't come out sideways. With the &lt;code&gt;Image&lt;/code&gt; + &lt;code&gt;URL.createObjectURL&lt;/code&gt; approach you have to handle orientation yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;OffscreenCanvas&lt;/code&gt; works on the main thread too.&lt;/strong&gt; You don't need a worker to use it, but you do need one if you don't want the UI to stutter on large images.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PNG ignores &lt;code&gt;quality&lt;/code&gt;.&lt;/strong&gt; That's not a bug — PNG is lossless, so the quality parameter simply does nothing. If a user asks you to "compress this PNG to 200 KB", your only real levers are reducing dimensions or switching to WebP (or JPEG if there's no transparency).&lt;/p&gt;

&lt;h2&gt;
  
  
  The hard part: a target file size
&lt;/h2&gt;

&lt;p&gt;Quality is not linear in bytes. Quality 0.8 might produce 180 KB on one photo and 40 KB on another, because it depends entirely on the content. So you can't compute the right quality — you have to search for it.&lt;/p&gt;

&lt;p&gt;Binary search converges in about 7 iterations, which is fast enough to feel instant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;compressToTarget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;minQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;maxQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.92&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OffscreenCanvas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drawImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;render&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;convertToBlob&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;image/jpeg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;quality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;q&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;minQ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;maxQ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;maxQ&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;best&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;best&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// keep the best that still fits&lt;/span&gt;
      &lt;span class="nx"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;best&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details that matter in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start from the top, not the middle.&lt;/strong&gt; Most images don't need to be compressed at all. Rendering at &lt;code&gt;maxQ&lt;/code&gt; first and bailing out early avoids seven pointless encodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The result is best-effort, not guaranteed.&lt;/strong&gt; If the image is so detailed that even &lt;code&gt;minQ&lt;/code&gt; exceeds the target, quality alone can't save you — you have to fall back to downscaling. Be honest in the UI about this; "target 100 KB" that quietly produces 340 KB is worse than saying "couldn't reach 100 KB at this width".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When quality isn't enough: shrink the canvas
&lt;/h2&gt;

&lt;p&gt;If the minimum acceptable quality still overshoots, reduce the long edge and try again. A simple approach is to step the width down by 10% and re-run the search, capped at a few attempts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;compressWithFallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;compressToTarget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createImageBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;resizeWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;resizeHeight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;resizeQuality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;high&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Could not reach target size&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Worth noting: &lt;code&gt;resizeQuality: "high"&lt;/code&gt; matters. The default is &lt;code&gt;"low"&lt;/code&gt;, which produces visibly soft results on downscales — the kind of thing that only shows up when someone zooms in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Batches are where it gets ugly
&lt;/h2&gt;

&lt;p&gt;Single-file compression is easy. Fifty files is a memory problem. A 40-megapixel image is 160 MB as an RGBA buffer, and each &lt;code&gt;OffscreenCanvas&lt;/code&gt; you keep alive holds one. Decode everything up front and you'll crash the tab on a laptop.&lt;/p&gt;

&lt;p&gt;The fix is boring: process sequentially, and release references as you go.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bitmap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createImageBitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;compressToTarget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;bitmap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;   &lt;span class="c1"&gt;// free the decoded buffer immediately&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;bitmap.close()&lt;/code&gt; is the important line. Without it, decoded bitmaps hang around until GC decides to run, and Chrome is conservative about that.&lt;/p&gt;

&lt;p&gt;If you want progress feedback without janking the UI, run the loop inside a Worker with &lt;code&gt;OffscreenCanvas&lt;/code&gt; — it's fully supported there, and you can post progress messages back as each file finishes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother compressing locally at all
&lt;/h2&gt;

&lt;p&gt;Beyond the obvious cost savings, there's a privacy argument that turns out to matter to users more than I expected: if compression happens in the page, the file never touches a server. For screenshots containing client data, medical images, internal dashboards, or anything under an NDA, "we don't upload it" is a feature you can actually promise rather than a line in a policy document.&lt;/p&gt;

&lt;p&gt;It's also why I ended up building &lt;a href="https://piczip.app" rel="noopener noreferrer"&gt;PicZip&lt;/a&gt; this way — no upload, no account, batch handling with a ZIP export, and a target-size field, because "make it smaller" is rarely the actual requirement. The whole thing is a static page; there's no backend to leak anything because there's no backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;createImageBitmap&lt;/code&gt; + &lt;code&gt;OffscreenCanvas&lt;/code&gt; replaces most server-side image pipelines for this kind of task.&lt;/li&gt;
&lt;li&gt;Binary search on quality converges fast, but always render the high end first and bail early.&lt;/li&gt;
&lt;li&gt;PNG has no quality knob — dimensions or format change are the only real levers.&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;bitmap.close()&lt;/code&gt; in batch loops or you will run out of memory on large photos.&lt;/li&gt;
&lt;li&gt;Tell the user when the target is unreachable instead of silently missing it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're doing this in production, the two things I'd test hardest are EXIF orientation across camera models and the memory ceiling on low-end phones with a full batch queued.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>performance</category>
      <category>frontend</category>
    </item>
    <item>
      <title>AddressLab: A Reproducible Workflow for Generating Valid Test Address Data</title>
      <dc:creator>qinjie xu</dc:creator>
      <pubDate>Thu, 01 Oct 2026 00:42:41 +0000</pubDate>
      <link>https://dev.to/qinjiexu2/addresslab-a-reproducible-workflow-for-generating-valid-test-address-data-1003</link>
      <guid>https://dev.to/qinjiexu2/addresslab-a-reproducible-workflow-for-generating-valid-test-address-data-1003</guid>
      <description>&lt;h2&gt;
  
  
  The Problem with Synthetic Address Data in CI Pipelines
&lt;/h2&gt;

&lt;p&gt;Every developer who builds location-aware features eventually hits the same wall: realistic address data for testing. Hardcoding a few US addresses works until your test matrix expands. You need tax-free states for e-commerce checkout flows, international formats for localization, and enough volume to stress pagination or geocoding APIs. Generating this manually wastes time; pulling from production risks PII exposure. The gap between "I need data" and "I have clean, safe test data" is where most workflows stall.&lt;/p&gt;

&lt;p&gt;This matters because modern AI and automation pipelines demand structured, varied inputs. Whether you're training a model on address parsing, testing a shipping calculator, or validating form field extraction, your test data needs to be reproducible, configurable, and exportable in formats your toolchain already consumes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What AddressLab Provides
&lt;/h2&gt;

&lt;p&gt;AddressLab is a free, no-sign-up US address generator that outputs structured location data without registration friction. It covers tax-free states (useful for sales-tax logic testing), includes multi-country address samples, and adds random email-format fields so you can test contact flows alongside physical addresses. Outputs save locally, with CSV or JSON export for direct pipeline injection.&lt;/p&gt;

&lt;p&gt;For developers building AI workflow automation—turning scattered tasks into repeatable pipelines—this eliminates a common preprocessing bottleneck. No API keys to manage, no rate limits to negotiate, no PII to sanitize.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Reproducible Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Define Your Test Matrix
&lt;/h3&gt;

&lt;p&gt;Before generating data, document what you actually need. A minimal matrix for a typical e-commerce or logistics pipeline:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;Values to Cover&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Country&lt;/td&gt;
&lt;td&gt;US (primary), CA, GB, DE, AU (secondary)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;US State Type&lt;/td&gt;
&lt;td&gt;Tax-free (AK, DE, MT, NH, OR), taxable, territory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Address Completeness&lt;/td&gt;
&lt;td&gt;Full, missing apartment, PO box, rural route&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Email Association&lt;/td&gt;
&lt;td&gt;Present, absent, malformed (for negative testing)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output Format&lt;/td&gt;
&lt;td&gt;JSON (API testing), CSV (spreadsheet/ML ingestion)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2: Generate and Capture from AddressLab
&lt;/h3&gt;

&lt;p&gt;Navigate to AddressLab and configure your parameters. The interface presents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Country selector&lt;/strong&gt;: US default, with additional countries as samples&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State filter&lt;/strong&gt;: Include/exclude tax-free states&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email toggle&lt;/strong&gt;: Append random email-format string to each record&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Count control&lt;/strong&gt;: Batch size for generation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export format&lt;/strong&gt;: JSON array or CSV with headers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Generate your first batch. For a 500-record US-only set with tax-free state coverage and email fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Typical&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;JSON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;structure&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;AddressLab&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"street"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"123 Main St"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Portland"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"OR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"zip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"97201"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"US"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user_7a3f@example.com"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file to your project's &lt;code&gt;test/fixtures/&lt;/code&gt; directory with a versioned filename: &lt;code&gt;addresses_v20241001_500.json&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Integrate into Your CI Pipeline
&lt;/h3&gt;

&lt;p&gt;Load the fixture directly or wrap it in a helper. Example for a Node.js test suite:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// test/helpers/addressLoader.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loadAddresses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;variant&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filePath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../fixtures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;`addresses_&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json`&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loadAddresses&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loadAddresses&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./helpers/addressLoader&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shipping calculator&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;loadAddresses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;v20241001_500&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OR&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;calculates zero tax for $state address&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;calculateTax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Maintain Reproducibility with Version Pinning
&lt;/h3&gt;

&lt;p&gt;The risk with any external data source is drift. AddressLab's local-save model helps here: once exported, your fixture is immutable. Document the generation parameters in a &lt;code&gt;FIXTURES.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Address Fixtures&lt;/span&gt;

| File | Source | Date | Count | Parameters |
|------|--------|------|-------|------------|
| addresses_v20241001_500.json | AddressLab | 2024-10-01 | 500 | US only, tax-free included, email enabled |
| addresses_v20241001_100_intl.json | AddressLab | 2024-10-01 | 100 | Multi-country, no email |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When your test matrix expands, generate a new fixture rather than mutating existing ones. This preserves historical test behavior and enables bisection if regressions appear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Validation and Debug Checks
&lt;/h2&gt;

&lt;p&gt;Before relying on generated data, verify these properties:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structural integrity&lt;/strong&gt;: Confirm every record has required fields. For US addresses: street, city, state, ZIP, country. Missing fields should fail your loader explicitly, not propagate as &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;State coverage&lt;/strong&gt;: If your logic branches on tax-free states, assert your fixture contains at least one example from each. A coverage gap here silently invalidates tax tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ZIP format validity&lt;/strong&gt;: US ZIPs should match &lt;code&gt;^\d{5}(-\d{4})?$&lt;/code&gt;. AddressLab generates realistic formats, but your pipeline should validate before passing to downstream services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Email field behavior&lt;/strong&gt;: When enabled, the email string follows &lt;code&gt;local@domain&lt;/code&gt; pattern but resolves to non-deliverable addresses by design. Confirm your system doesn't accidentally send to them during integration tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;International format variance&lt;/strong&gt;: Non-US addresses from the multi-country sample use local conventions (postal codes, province names, address ordering). Verify your parser handles these without US-centric assumptions.&lt;/p&gt;

&lt;p&gt;Run a smoke check on each new fixture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Example validation script&lt;/span&gt;
node &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"
const data = require('./test/fixtures/addresses_v20241001_500.json');
const states = new Set(data.map(d =&amp;gt; d.state));
const required = ['OR', 'DE', 'AK', 'MT', 'NH']; // tax-free baseline
const missing = required.filter(s =&amp;gt; !states.has(s));
if (missing.length) throw new Error('Missing states: ' + missing);
console.log('Fixture valid:', data.length, 'records,', states.size, 'unique states');
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extending the Workflow
&lt;/h2&gt;

&lt;p&gt;For teams running larger test suites or ML training pipelines, consider these extensions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parameterize fixture selection&lt;/strong&gt;: Use environment variables to switch between small (fast unit tests) and large (integration/performance tests) fixtures without code changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generate diffs on schema changes&lt;/strong&gt;: If AddressLab updates its export format, compare against your pinned fixtures to catch breaking changes before they reach CI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Combine with property-based testing&lt;/strong&gt;: Use AddressLab for seed data, then apply tools like fast-check or Hypothesis to mutate fields and test edge cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;Reliable test data is infrastructure, not an afterthought. AddressLab removes the friction of generating structured address fixtures while keeping your data local, versionable, and pipeline-ready. If your team needs repeatable location data for CI, the workflow above gives you a concrete starting point without external dependencies or compliance overhead.&lt;/p&gt;

&lt;p&gt;For the current interface and export options, see &lt;a href="https://addresslab.net/" rel="noopener noreferrer"&gt;AddressLab&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>softwaredevelopment</category>
      <category>testing</category>
    </item>
    <item>
      <title>Using ChatMock to Generate Reproducible Chat UI Fixtures for UI Testing and Prototyping</title>
      <dc:creator>qinjie xu</dc:creator>
      <pubDate>Mon, 14 Sep 2026 13:19:14 +0000</pubDate>
      <link>https://dev.to/qinjiexu2/using-chatmock-to-generate-reproducible-chat-ui-fixtures-for-ui-testing-and-prototyping-5flg</link>
      <guid>https://dev.to/qinjiexu2/using-chatmock-to-generate-reproducible-chat-ui-fixtures-for-ui-testing-and-prototyping-5flg</guid>
      <description>&lt;h2&gt;
  
  
  The Problem: Chat UI Fixtures Are Hard to Keep Consistent
&lt;/h2&gt;

&lt;p&gt;Anyone who has built a chat interface—whether for a support widget, an onboarding flow, or a messaging feature—knows the pain of maintaining realistic test fixtures. Screenshots taken from live apps are fragile: they carry real user data, vary by device, get stale, and usually require someone with access to a production environment to refresh them. Manually editing HTML or constructing JSON payloads for mocked conversations adds friction to every sprint cycle.&lt;/p&gt;

&lt;p&gt;ChatMock is a browser-based tool that generates realistic chat mockups for WhatsApp, Messenger, Instagram DM, and similar interfaces. It runs entirely in the browser, requires no signup, and applies no watermark. For teams that need reproducible visual fixtures—for UI review, design handoff, or documentation—this is a meaningful constraint to evaluate: zero server-side upload means the fixture workflow stays local and auditable.&lt;/p&gt;

&lt;p&gt;This article walks through a concrete workflow for integrating ChatMock into a UI fixture pipeline, including reproducibility considerations, a sample fixture spec, and quality checks you can apply before committing assets.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technical Context: What "Browser-Only" Actually Means for Your Pipeline
&lt;/h2&gt;

&lt;p&gt;When a tool advertises that everything renders in the browser, it has a specific implication for reproducibility: there is no shared server state, no API call that could return different results on a different day, and no account-level configuration that silently changes output.&lt;/p&gt;

&lt;p&gt;For chat UI fixtures, this is useful in two scenarios:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Snapshot testing baselines&lt;/strong&gt; — You want a fixture that looks the same every time it is captured, so visual regression tools (Percy, Chromatic, BackstopJS) can diff against a stable baseline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation and handoff&lt;/strong&gt; — Design specs and README screenshots need to stay accurate without requiring a live environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The tradeoff is that browser-rendered tools are generally not scriptable via CLI. The fixture generation step is manual, which means you need a deterministic input spec so that any team member can reproduce the same output. The workflow below addresses that.&lt;/p&gt;




&lt;h2&gt;
  
  
  Setup: Defining a Reproducible Fixture Spec
&lt;/h2&gt;

&lt;p&gt;Before opening the tool, define your fixture as a plain text or JSON spec. This becomes the source of truth that lives in your repository and can be reviewed in pull requests.&lt;/p&gt;

&lt;p&gt;Example fixture spec file (&lt;code&gt;fixtures/onboarding-chat.fixture.json&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"platform"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"whatsapp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"fixture_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"onboarding-welcome-v2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"participants"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"handle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Support Bot"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"avatar"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bot"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"handle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"New User"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"avatar"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"person"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Welcome! How can I help you get started today?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10:01"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"I just signed up and I'm not sure where to begin."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10:02"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"No problem. Let me walk you through the first three steps."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10:02"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Step 1: Connect your data source. Step 2: Configure your first workflow. Step 3: Run a test message."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10:03"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Got it, thanks!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10:04"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"export_format"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"resolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2x"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"notes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Used for onboarding docs and README header. Regenerate if copy changes."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This spec is human-readable, diffable in Git, and gives any team member the exact inputs needed to regenerate the fixture using &lt;a href="https://chatmock.net/" rel="noopener noreferrer"&gt;ChatMock&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Workflow: Generating and Capturing the Fixture
&lt;/h2&gt;

&lt;p&gt;With the spec committed, the generation steps are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Load the platform template.&lt;/strong&gt;&lt;br&gt;
Open ChatMock, select the target platform (e.g., WhatsApp). The interface renders a phone-frame mockup with editable message fields.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Populate from the spec.&lt;/strong&gt;&lt;br&gt;
Enter the messages in sequence, matching the &lt;code&gt;from&lt;/code&gt;, &lt;code&gt;text&lt;/code&gt;, and &lt;code&gt;time&lt;/code&gt; fields from the fixture spec. For multi-participant threads, assign the correct sender role to each bubble.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Verify visual state before capture.&lt;/strong&gt;&lt;br&gt;
Before exporting, run through the quality checklist in the next section. Common issues include mismatched timestamps, truncated long messages, and incorrect bubble alignment (sent vs. received).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 — Export and commit.&lt;/strong&gt;&lt;br&gt;
Export the rendered mockup (PNG at 2x if the tool supports it, or capture at device-pixel-ratio 2 using a browser screenshot extension). Save to &lt;code&gt;fixtures/assets/onboarding-welcome-v2.png&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5 — Update the spec &lt;code&gt;notes&lt;/code&gt; field&lt;/strong&gt; with the date and the reason for the regeneration, then commit both the spec and the asset together.&lt;/p&gt;

&lt;p&gt;Example commit message convention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fix(fixtures): regenerate onboarding-welcome-v2 for updated step copy

Spec: fixtures/onboarding-chat.fixture.json
Asset: fixtures/assets/onboarding-welcome-v2.png
Tool: ChatMock (browser-rendered, no upload)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps the asset traceable to the spec without any external service dependency.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quality Checks Before Committing a Fixture
&lt;/h2&gt;

&lt;p&gt;For chat mockups to be useful as test fixtures or documentation assets, apply these checks before treating a render as final:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bubble alignment check&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sent messages (agent or bot) should appear on the correct side for the target platform. WhatsApp places sent messages on the right; verify this matches your fixture spec's &lt;code&gt;role&lt;/code&gt; assignments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Timestamp consistency check&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Timestamps in the mockup should be monotonically increasing and match the &lt;code&gt;time&lt;/code&gt; values in the spec. Mismatched times introduce confusion in documentation that describes a sequence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Text truncation check&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If a message contains more than ~160 characters, verify it wraps correctly within the bubble and is not clipped. Capture the full message area in your screenshot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Platform chrome accuracy&lt;/strong&gt;&lt;br&gt;
Compare the rendered header (contact name, status indicator, platform-specific icons) against a reference screenshot of the actual platform. For documentation purposes, the chrome should be close enough that readers recognize the interface at a glance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watermark / attribution check&lt;/strong&gt;&lt;br&gt;
ChatMock exports without a watermark, which is a stated feature. Verify the exported PNG contains no overlay text or logo before using it in production documentation or public-facing materials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reproducibility smoke test&lt;/strong&gt;&lt;br&gt;
Have a second team member follow the spec independently and compare the output. Pixel-perfect parity is not the goal; structural and copy parity is. If the two outputs differ in message order or copy, the spec is ambiguous and needs tightening.&lt;/p&gt;

&lt;p&gt;A lightweight test matrix for tracking fixture status:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fixture ID&lt;/th&gt;
&lt;th&gt;Platform&lt;/th&gt;
&lt;th&gt;Last Generated&lt;/th&gt;
&lt;th&gt;Spec Version&lt;/th&gt;
&lt;th&gt;Alignment OK&lt;/th&gt;
&lt;th&gt;Timestamps OK&lt;/th&gt;
&lt;th&gt;Truncation OK&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;onboarding-welcome-v2&lt;/td&gt;
&lt;td&gt;WhatsApp&lt;/td&gt;
&lt;td&gt;2026-09-14&lt;/td&gt;
&lt;td&gt;v2&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;support-error-state-v1&lt;/td&gt;
&lt;td&gt;Messenger&lt;/td&gt;
&lt;td&gt;2026-08-30&lt;/td&gt;
&lt;td&gt;v1&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;⚠️&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Track this matrix in a &lt;code&gt;FIXTURES.md&lt;/code&gt; file alongside the spec JSON files.&lt;/p&gt;




&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;Browser-only, no-signup tooling like ChatMock shifts the reproducibility problem from infrastructure to process. The tool itself has no state to drift; your fixture spec is the single source of truth. For teams that already use snapshot testing or maintain documentation screenshots, layering a structured spec file and a commit convention on top of the mockup generation step is a low-overhead way to keep visual fixtures reviewable and auditable.&lt;/p&gt;

&lt;p&gt;If your team maintains chat UI fixtures manually or relies on screenshots from live environments, adopting a spec-driven approach reduces the surface area for inconsistency without requiring any new infrastructure. The workflow above is directly adoptable: copy the fixture spec schema, adapt the message content, and establish the commit convention as a contribution guideline.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>testing</category>
      <category>tools</category>
      <category>ui</category>
    </item>
  </channel>
</rss>
