<?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 Maggie Kwan on Medium]]></title>
        <description><![CDATA[Stories by Maggie Kwan on Medium]]></description>
        <link>https://medium.com/@kwanmym?source=rss-d29e8e7874e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ut8Qy5HiCXtza3t9eN6ixA.png</url>
            <title>Stories by Maggie Kwan on Medium</title>
            <link>https://medium.com/@kwanmym?source=rss-d29e8e7874e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:21:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kwanmym/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[Automated Test Generation with Chromogen 5.0]]></title>
            <link>https://medium.com/@kwanmym/automated-test-generation-with-chromogen-5-0-2dc0475673e4?source=rss-d29e8e7874e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dc0475673e4</guid>
            <dc:creator><![CDATA[Maggie Kwan]]></dc:creator>
            <pubDate>Thu, 02 Mar 2023 01:21:39 GMT</pubDate>
            <atom:updated>2023-03-04T01:54:27.265Z</atom:updated>
            <content:encoded><![CDATA[<p>Generate unit tests for your Recoil and Zustand projects by interacting with your application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vPd-n-xrRMLLHfYH36BK5Q.png" /><figcaption>Chromogen Logo</figcaption></figure><p><strong>What is Chromogen?</strong></p><p>Chromogen is a unit test generator for React state management libraries. It currently supports Zustand and Recoil applications. After installing Chromogen using the following command,</p><pre>npm install chromogen</pre><p>import the ChromogenObserver into your application and wrap it around the components rendered in /YourApp. For Zustand:</p><pre>import React from &#39;react&#39;;<br>import { ChromogenZustandObserver } from &#39;chromogen&#39;;<br>import YourApp from &#39;./YourApp&#39;;</pre><pre>const App = () =&gt; (<br>  &lt;&gt;<br>    &lt;ChromogenZustandObserver&gt;<br>      &lt;YourApp /&gt;<br>    &lt;/ChromogenZustandObserver&gt;<br>  &lt;/&gt;<br>);<br>export default App;</pre><p>Next, import ChromogenZustandMiddleware and wrap it around your useStore function as demonstrated below. You’ll also need to add additional arguments to the set function:<br>1) Overwrite state (boolean) — false is the default, but this needs to be stated explicitly when using Chromogen<br>2) Action name (string) — string of the action name<br>3) Action parameter(s) — if the action has one or more parameter, pass them in the same order after the action name string</p><pre>import { create } from &#39;zustand&#39;;<br>import { chromogenZustandMiddleware } from &#39;chromogen&#39;;<br><br> const useStore = create(<br>  chromogenZustandMiddleware((set) =&gt; ({<br>    count: 1,<br>    color: &#39;peru&#39;,<br>    increment: () =&gt; set((state) =&gt; ({ count: state.count + 1 }), false, &#39;increment&#39;)<br>    changeColor: (newColor) =&gt; set(() =&gt; ({ color: newColor }), false, &#39;changeColor&#39;, newColor),<br>  }))<br>);<br><br><br>export  default useStore;</pre><p>Now you can start generating tests! For instructions for use with Recoil applications, please refer to the <a href="https://github.com/open-source-labs/Chromogen">Github repository</a>.</p><p><strong>Visualizing Updates in Instantaneously</strong></p><p>Previously, in order to see test if changes made to the Chromogen codebase were behaving as expected, you would need to update its npm library with the changes you made. This was a time-consuming process, especially since each team member would probably be doing this several times a day.</p><p>Instead of installing the Chromogen npm package into our demo, we installed the local Chromogen package. However, this created a symlink pointing to the local Chromogen package in the demo’s node_modules . This resulted in compatibility issues.</p><p>Our solution was to create a .tar archive within the demo and compress it into a .tgz file. This will solve the symlink compatibility issue. We combined the npm scripts that will allow us to see our updates immediately into one simple script that you will run in the demo:</p><pre>npm run tarballUpdate</pre><p><strong>Containerization with Docker</strong></p><p>Containers are packages that can be used to wrap your software along with its libraries, dependencies, and configuration files into a lightweight and portable runtime environment. This enables your application to be run reliably across all computing environments.</p><p>We containerized Chromogen using Docker to prevent issues that may arise with dependency conflicts similar to what we encountered with the symlink. Our goal was to ensure that any future contributors to the product can immediately run the application on their machines, regardless of their local environment.</p><p><strong>UI / UX Overhaul</strong></p><p>Chromogen 5.0 is updated with a new graphical user interface that now displays the generated tests in real time. It is rendered alongside your Recoil or Zustand application, so it will no longer interfere when the user is interacting with their app. Users also have the option to collapse the Chromogen interface with the simple click of a button. Best of all, users have the ability to edit the tests right on the interface!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ifUFqJLpmFSFnUWoILdGMQ.gif" /></figure><p><strong>Continuous Integration with Jenkins</strong></p><p>Just as automation is useful in generating unit tests, it can also facilitate the development process for teams of two or more developers. Whenever multiple team members are integrating code into a central repository, they may encounter a merge conflict. The likelihood of this is positively correlated with the number of changes between each merge.</p><p>This is why we decided to establish a continuous integration (CI) environment in Chromogen’s latest version. CI is a practice in which merging occurs more frequently and automatically. For instance, instead of team members manually merging after the completion of a new feature, each commit would trigger an automated build and the option to run automated testing as well. We built a pipeline using Jenkins that automates both the build and testing.</p><p>While the initial set-up is tedious and time consuming, it will ultimately make it easier and quicker to pinpoint and address bugs, and allow the team to work quickly while maintaining high quality standards.</p><p>You will need to have <a href="https://docs.docker.com/get-docker/">Docker installed</a> to run Jenkins. Run the following command to create a bridge network for Jenkins:</p><pre>docker network create jenkins</pre><p>Enable Docker commands to be executable within Jenkins nodes:</p><pre>docker run \<br>  --name jenkins-docker \<br>  --rm \<br>  --detach \<br>  --privileged \<br>  --network jenkins \<br>  --network-alias docker \<br>  --env DOCKER_TLS_CERTDIR=/certs \<br>  --volume jenkins-docker-certs:/certs/client \<br>  --volume jenkins-data:/var/jenkins_home \<br>  --publish 2376:2376 \<br>  --publish 3003:3003 --publish 5003:5003 \<br>  docker:dind \<br>  --storage-driver overlay2</pre><p>Build a Docker image from the Dockerfile within Chromogen:</p><pre>docker build -t chromogen-jenkins .</pre><p>Run your chromogen-jenkins image in Docker as a container:</p><pre>docker run \<br>  --name jenkins-blueocean \<br>  --detach \<br>  --network jenkins \<br>  --env DOCKER_HOST=tcp://docker:2376 \<br>  --env DOCKER_CERT_PATH=/certs/client \<br>  --env DOCKER_TLS_VERIFY=1 \<br>  --publish 8080:8080 \<br>  --publish 50000:50000 \<br>  --volume jenkins-data:/var/jenkins_home \<br>  --volume jenkins-docker-certs:/certs/client:ro \<br>  --volume &quot;$HOME&quot;:/home \<br>  --restart=on-failure \<br>  --env JAVA_OPTS=&quot;-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true&quot; \<br>  myjenkins-blueocean:2.375.3-1</pre><p>Navigate to your <a href="http://localhost:8080/">localhost:8080</a> and enter the password (between the two sets of asterisks) that is generated from the following command:</p><pre>docker logs jenkins-blueocean</pre><p>Create your first administrator user.</p><p>Stop and start your Docker container using one of the following:</p><pre>docker stop jenkins-blueocean jenkins-docker<br>docker start jenkins-blueocean jenkins-docker</pre><p>When configuring your pipeline, make sure to set your pipeline definition to <em>Pipeline Script from SCM </em>and enter the path to your local repository, specify the brand you are working from, set the Script Path to <em>jenkins/Jenkinsfile</em>, and uncheck <em>Lightweight Checkout</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IB_rYAVKBWLhT9BpCRSzwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfYha2JrrAx3CuW4Hom13w.png" /></figure><p>Congratulations, now you are ready to continuously integrate!</p><p><strong>How to Contribute to Chromogen Product Development</strong></p><p>Chromogen was released under the MIT license in September 2020 and is in active development through OSLabs. It is a fully open source product. If you would like to contribute, please visit</p><p><a href="https://github.com/open-source-labs/Chromogen">Github</a><br><a href="https://www.linkedin.com/company/chromogen/">Linkedin</a><br>Website</p><p><strong>The Chromogen 5.0 Team</strong></p><p><a href="https://github.com/sirbrachthepale">Brach Burdick</a><br><a href="https://github.com/dnvt">Francois Denavaut</a><br><a href="https://github.com/maggiekwan">Maggie Kwan</a><br><a href="https://github.com/Lawliang">Lawrence Liang</a></p><p>Our team would like to thank the developers who have contributed to previous versions of Chromogen, Michelle Holland, Andy Wang, Connor Rose Delisle, Jim Chen, Amy Yee, Jinseon Shin, Ryan Tumel, Cameron Greer, Nicholas Shay, Marcellies Pettiford, Sung Kim, Lina Lee, Erica Oh, Dani Almaraz, Craig Boswell, Hussein Ahmed, Ian Kila. And a special thanks to Yuehao Wong for his mentorship!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dc0475673e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>