<?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 StackAnatomy Owner on Medium]]></title>
        <description><![CDATA[Stories by StackAnatomy Owner on Medium]]></description>
        <link>https://medium.com/@stackanatomy?source=rss-de040aca1be7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rMfOrzM5XI3hEGXX_4nxaQ.png</url>
            <title>Stories by StackAnatomy Owner on Medium</title>
            <link>https://medium.com/@stackanatomy?source=rss-de040aca1be7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 06:07:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stackanatomy/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[Building a Progressive Web App with React 18]]></title>
            <link>https://medium.com/stackanatomy/building-a-progressive-web-app-with-react-18-ae5195977350?source=rss-de040aca1be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae5195977350</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[StackAnatomy Owner]]></dc:creator>
            <pubDate>Sat, 16 Apr 2022 00:00:00 GMT</pubDate>
            <atom:updated>2022-04-22T11:13:50.116Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn the basics of PWAs and how to get started with React 18</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfG9Hp8XCwZQWWcxXl3Dxw.png" /></figure><p>When some websites get visited on a smartphone, the website prompts the user to install itself into the user’s device like an app. When “downloaded” into the user’s device, these websites have almost the same features a native mobile app would. They even have icons that can be viewed on the user’s home screen. When a website has been built in such a way, then we say the website is a Progressive Web App.</p><h3>What is a Progressive Web App (PWA) and how does it work?</h3><p>A progressive Web App is a website that can behave like a native app. This is possible due to the additional customizations done to the Web app or website, which gives these capabilities. Some features a PWA is capable of include push notifications, the ability to work on Android and IOS without much difference, a regular icon on the home screen of the user’s device like a standard app would, and the ability to work offline.</p><p>Here are some reasons why Progressive Web Apps are to be chosen or used by developers.</p><ul><li>Lower Costs: Building a native mobile app or desktop app requires a budget for hiring a developer. But with PWAs, a mobile developer is not needed as a website can be converted straight away into a Progressive Web App,</li><li>Time Saved: A PWA saves time that would’ve been spent building a mobile app. The same codebase can be shared across multiple platforms and still look and feel good.</li><li>Lightweight: PWAs are lightweight, not heavy and bulky. This helps the web app have faster loading times and optimum memory utilization.</li><li>Cross-Platform: PWAs are cross-platform. They run in Android, IOS, Windows, and even MacOS, accessible with any device with a browser.</li><li>Fast Update: A Progressive Web App does not need an update to be installed for it separately on any platform it is on. It updates on its own since it technically is a website.</li></ul><p>In this article, we will be building a simple note-taking app with React JS and then making it a Progressive Web App.</p><h3>Creating the project</h3><p>We will use React 18 (the latest version of React JS) to build this project. Remember, we need to have Node version 14.0.0 (or higher) and npm version 5.6 or more to use React 18.</p><pre>npx create-react-app notes</pre><p>And then we have our react notes app load.</p><p>After it is installed, we will run:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/437f7b78253db366909599748da59b0f/href">https://medium.com/media/437f7b78253db366909599748da59b0f/href</a></iframe><p>After this, we can also proceed to open our newly created react app on our favorite code editor,</p><h3>Creating the Page</h3><p>And now, we will create our homepage with contain our App component. In the index.js, we have:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70fd0363da4553d3d1239649739d72ea/href">https://medium.com/media/70fd0363da4553d3d1239649739d72ea/href</a></iframe><p>And in our App.js we have</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2feec23e600a1fd48f41cbd265567dc6/href">https://medium.com/media/2feec23e600a1fd48f41cbd265567dc6/href</a></iframe><p>And now we have this displayed on our page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/0*xBy3ols2mGNWmxIu.png" /></figure><h3>Creating the Notes Component</h3><p>We will create a Notes component that will display any available notes. The component will be inside a folder, and the folder will be created inside the src folder and called components.</p><p>After that, we will create a file called Notes.js inside the components folder and create a simple function that loops through available data served in the props, creating different p elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/0*1X6otHiOpFR9xxSX.png" /></figure><p>Inside the Notes.js file, we have:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/373066e0bc7adacafa80a74e69e5e5af/href">https://medium.com/media/373066e0bc7adacafa80a74e69e5e5af/href</a></iframe><p>This means that our Notes component will always take the parameter data. Now to import it into our App.js, we have:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a95dac5ad346cda971c9ae1513ea2933/href">https://medium.com/media/a95dac5ad346cda971c9ae1513ea2933/href</a></iframe><p>Remember, our Notes component needs parameter data. We will create states for the data that will update whenever the save button is clicked.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98fa2f94750c26ffd27998cc670b38e2/href">https://medium.com/media/98fa2f94750c26ffd27998cc670b38e2/href</a></iframe><p>And now, we should be able to save some notes with our app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/0*UByVeb-vPiI9E96W.gif" /></figure><h3>Registering our Service Worker</h3><p>What is a service worker? A service worker is just a required JS program for our app to be a Progressive Web App.</p><p>So, to use a service worker, we will have to register it on our index.js, so we import serviceWorker.js into our index.js.</p><p>index.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87df4d9a896f7cbc9bc2acfd1fcc868e/href">https://medium.com/media/87df4d9a896f7cbc9bc2acfd1fcc868e/href</a></iframe><h3>Editing our manifest.json file</h3><p>The final step to making our app a PWA is to change some things in our manifest.json file. We will set our icons and other options available.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47d37a113331df7c5e3517c3ecf1170c/href">https://medium.com/media/47d37a113331df7c5e3517c3ecf1170c/href</a></iframe><p>And finally, we have a PWA app working that can run on any device like a native app.</p><h3>Open Source Session Replay</h3><p><a href="https://github.com/openreplay/openreplay"><em>OpenReplay</em></a><em> is an open-source alternative to FullStory and LogRocket. It gives you full observability by replaying everything your users do on your app and showing how your stack behaves for every issue. OpenReplay is self-hosted for full control over your data.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M0XYegtL4-6FwqHZ.png" /></figure><p><em>Happy debugging for modern frontend teams — </em><a href="https://github.com/openreplay/openreplay"><em>start monitoring your web app for free</em></a><em>.</em></p><h3>Conclusion</h3><p>Progressive Web Applications will continue to be used to enhance the mobile experience of websites in the nearest future as it is a cheaper alternative to building native mobile apps from scratch — and React JS happens to come with some functionalities for converting a React app straight into a Progressive Web App.</p><p>This project’s source code can be found in <a href="https://stackblitz.com/edit/react-m2l1cn">Stackblitz</a>.</p><p><em>Originally published at </em><a href="https://blog.openreplay.com/building-a-progressive-web-app-with-react-18"><em>https://blog.openreplay.com</em></a><em> on April 16, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae5195977350" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackanatomy/building-a-progressive-web-app-with-react-18-ae5195977350">Building a Progressive Web App with React 18</a> was originally published in <a href="https://medium.com/stackanatomy">StackAnatomy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperapp — Is It the Lightweight ‘React Killer’?]]></title>
            <link>https://medium.com/stackanatomy/hyperapp-is-it-the-lightweight-react-killer-ff80a0fa3c61?source=rss-de040aca1be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff80a0fa3c61</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[StackAnatomy Owner]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 00:00:00 GMT</pubDate>
            <atom:updated>2021-04-07T10:31:24.355Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hyperapp — Is It the Lightweight ‘React Killer’?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XGbqf1uPqIY6KXplytW9dA.png" /></figure><p>For a while now, JavaScript and its ecosystem have been thriving. From different tooling categories, <strong>UI frameworks</strong> have enjoyed immense popularity. New libraries and frameworks seem to pop up almost every day, while Vue, React, and Angular persistently lead the way.</p><p>From these new options, there are some that deserve your attention. I’m thinking Svelte, Solid, and <strong>Hyperapp</strong> — an ultra-lightweight UI framework that we’ll be taking a further look at.</p><h3>What is Hyperapp?</h3><p>Hyperapp isn’t really that new. It’s been around since <a href="https://github.com/jorgebucaran/hyperapp/commit/72f764932a619f415e2f4f5cefdfc4cef5a94511">the end of 2016</a> and gained a lot of popularity over this period. It’s gained over <strong>18K GitHub stars</strong> on its repo and over <strong>2.5K weekly downloads</strong> on NPM.</p><p>It’s easy to see why so many developers got interested in the library given its feature set. <a href="https://bundlephobia.com/result?p=hyperapp">Tiny footprint</a>, high performance, simplistic architecture, and development experience designed around not using any bundler or compiler — these are all very useful features.</p><h3>v2</h3><p>Hyperapp reached its popularity peak middle of 2020 and dropped quite a bit since. That’s potentially due to the rise of v2 of the framework, which, although brought many improvements, also came with many breaking changes.</p><p>These breaking changes caused the already small ecosystem to crumble and the loss of some handy features like <a href="https://github.com/jorgebucaran/hyperapp/pull/1011">JSX</a>, and <a href="https://github.com/jorgebucaran/hyperapp/pull/1016">TypeScript typings</a>, with both being still worked on for v2.</p><h3>Bright future</h3><p>With that said, Hyperapp still has a bright future ahead of it. Given all of its current advantages and continuous improvements, the framework is on track to match or surpass its prior popularity peak.</p><p>Now, to give you a better sense of what Hyperapp is about, let’s compare it with the most well-known JS UI library out there — React.</p><h3>Comparing performance</h3><p>Let’s start with performance — one of the strongest advantages of Hyperapp.</p><h4>Benchmark</h4><p>For such comparisons, I often start with an awesome, <a href="https://github.com/krausest/js-framework-benchmark">open-source benchmark</a> that covers many JS UI frameworks and libraries — including Hyperapp. You can see the most recent results <a href="https://krausest.github.io/js-framework-benchmark/current.html">here</a>, and an example table below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*olFoV1LMgYH9N-dP.png" /></figure><p>Although synthetic benchmarks don’t always reflect real-world performance, they provide us with a rough, easy-to-compare metric.</p><p>Above, you can see Hyperapp trading blows with Solid and Svelte. It’s a very impressive result, especially considering that we’re comparing compiler-backed frameworks to a pure-runtime one.</p><p>As for React — it’s the last in the whole group. That’s nothing new, considering that React isn’t known for its high performance, rather than the ecosystem, innovation, and overall leading the trends.</p><h4>Bundle size</h4><p><strong>Size</strong> is another metric determining the overall framework’s performance. Although it’s becoming increasingly less important with modern devices and high-speed connections, it’s still worth considering for low-end devices and other constrained environments.</p><p>Hyperapp’s <a href="https://bundlephobia.com/result?p=hyperapp">really lightweight</a> — about <strong>1.7KB</strong> minified + gzipped (what’s downloaded), and <strong>3.7KB</strong> minified (what’s parsed and executed). That’s for Hyperapp core library, which is perfectly usable on its own.</p><p>As for <a href="https://bundlephobia.com/result?p=react">React</a>, we’ve got <strong>2.8KB</strong> min-gzip and <strong>7KB</strong> min-only. That’s already almost ×2 the size of Hyperapp, and it goes much higher when we factor in <a href="https://bundlephobia.com/result?p=react-dom@17.0.1">react-dom</a> (required for rendering to DOM) — <strong>39.4KB</strong> min-gzip and <strong>121.1KB</strong> min-only.</p><p>These results translate nicely into the startup timing, measured by the previously-mentioned benchmark:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/0*-mHJWBVkBPcBJSqB.png" /></figure><p>Obviously, these benefits come at the cost of the framework’s feature set. Its minimalism and simplicity might not be good for everyone, but it’s just enough to get the job done. Let’s see how it compares in this regard.</p><h3>Comparing architecture and reactivity model</h3><p>Framework’s architecture, design, and API are what determines the end development experience and workflow. In the case of Hyperapp, it’s clearly going the minimalistic route, packing only the features you need while focusing heavily on performance. How does it affect its usability?</p><h4>Initial setup</h4><p>Right from the start, you can see stark differences between React and Hyperapp’s philosophies. While React pushes you towards packages &amp; bundlers or CDNs, Hyperapp focuses on native <strong>ESM modules</strong>. Take a look at a primary example from the README:</p><p>You can see how Hyperapp focuses on pure JS, runtime-based usage. That’s why things like TypeScript or JSX support aren’t the highest priority.</p><p>This focus makes such high levels of performance possible, and it’s why the framework is so simple and minimalist.</p><p>On the contrary, React focuses extensively on JSX and thus requires code pre-processing. It’s not to say that this approach is worse or better in any regard — it’s just different.</p><p>With that said, both frameworks can still be used in a variety of ways. It’s just that Hyperapp presents a pure, no-bundlers ESM module way as an official recommendation for production.</p><h4>Templating syntax</h4><p>As far as creating your views go, both React and Hyperapp work similarly under-the-hood. It’s just that React’s support and push towards JSX made it the go-to choice.</p><p>In the case of Hyperapp, again, the support for JSX is <a href="https://github.com/jorgebucaran/hyperapp/pull/1011">in the works</a>, but it’s not the primary focus anyway. Instead, it’s the React.createElement() equivalent in the form of h() , and text() functions. If you&#39;re wondering why text() is a thing - it&#39;s for <a href="https://github.com/jorgebucaran/hyperapp/issues/1009#issuecomment-757694817">additional performance</a>.</p><p>If you don’t want to repeatedly type h(&quot;tag&quot;, ...), then you could look into the official @hyperapp/html package. It&#39;s a collection of shortcut functions that simplify h() calls to tag() calls, while still being usable without bundlers. Here&#39;s an example:</p><p><strong>JSX support</strong> With that said, it’s easy to see how JSX might still be more appealing than both of the provided syntaxes.</p><p>To be fair, <a href="https://github.com/jorgebucaran/hyperapp/issues/989#issuecomment-732165556">there are ways</a> to use Hyperapp with JSX or even template literals already. It’s just that as long as the official support is in development, it’s hard to pick the “go-to” implementation.</p><p>Hyperapp’s flexibility allows you to use many view-constructing syntaxes, given some time and effort. Though, most of them will come with additional complexity and potential performance decrease.</p><h4>Components</h4><p>Both Hyperapp and React allow you to create components for better reusability of UI logic. In React, components can be created as plain functions but with predictable structure, and they can have a local state.</p><p>As for Hyperapp, its components look similar. However, unless you want to use a specific templating syntax, you don’t have to stick to any structure. Just make it so that your function results in the creation of some virtual nodes ( h() and text() returns), and that&#39;s it!</p><p>Now, arguably you could do the same in React without JSX, but it wouldn’t seem equally natural. And aside from that, passing accepting props object as the only parameter is a good base practice.</p><p><strong>No local state</strong> With that said, there’s one big difference between Hyperapp and React components, and it’s the absence of a local state.</p><p>In Hyperapp, the entire state is defined at the very start of an app and has to be passed down the node tree. It can then be interacted with using actions, effects and subscriptions.</p><h4>Reactivity</h4><p>Implementation of reactivity (state management, view updates, etc.) is where the two frameworks differ immensely.</p><p><strong>React hooks</strong> On the side of React, <strong>hooks</strong> have been the primary way of adding reactivity to your components for quite a while now.</p><p>They’ve been well received, and the core ideas behind them have inspired the likes of <a href="https://v3.vuejs.org/guide/composition-api-introduction.html">Vue’s Composition API</a> and a big part of <a href="https://github.com/ryansolid/solid/blob/master/documentation/api.md">Solid’s API</a>.</p><p><strong>Hyperapp API</strong> Hyperapp takes a different approach. Instead of just hooks, you’ve got actions, effects, and subscriptions.</p><p>It might seem a bit complex at first, but it really isn’t, and additional separation allows for an easier understanding of all the concepts, which are just that — concepts! They’re either simple functions with expected input and output or data structures fitting given requirements.</p><p>There are no additional APIs. In fact, the entire API of the framework is just the h() and text() templating functions, as well as app() serving as an entry point for any Hyperapp app and memo() for easy view memoization. That&#39;s fewer functions in the entire framework than <a href="https://reactjs.org/docs/hooks-reference.html">core hooks</a> in React!</p><p>Now, we won’t be diving deep into these Hyperapp concepts and APIs; however few there might be. Instead, let’s do a quick rundown. <strong>App</strong> We start from an app() call, which initializes and mounts Hyperapp to DOM.</p><p>init is where the state gets initialized, view serves as the main rendering function, and node as the mounting point.</p><p><strong>Actions</strong> To <strong>change the state</strong>, you have to use actions — functions which, given the current state and additional payload, output a new state.</p><p>You can use actions in DOM event listeners, subscriptions, and even the init property for complex state initializations.</p><p><strong>Subscriptions</strong> Subscriptions provide <strong>a way for dispatching actions</strong>, and related side-effects, based on events outside of Hyperapp’s control.</p><p>Subscriptions are tuples, i.e., 2-element arrays, where the first value is the subscription’s function, and the second one is props to be passed to it.</p><p>You can register subscriptions from the app() call under the subscriptions property. There, you can add or remove your subscriptions based on the current state.</p><p><strong>Effects</strong> As for the mentioned effects, they can be used for handling <strong>side-effects</strong>, like data fetching.</p><p>Like subscriptions, effects are tuples consisting of a function and props and can be executed by actions when they return an array of the new state and all the effects instead of the new state directly.</p><h3>Observability for Production React Apps</h3><p>Debugging React apps in production may be challenging and time-consuming. Asayer is a frontend monitoring tool that replays everything your users do and shows how your app behaves and renders for every issue. It’s like having your browser’s inspector open while looking over your user’s shoulder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*itdjPpv0lahAGam2.png" /></figure><p>Asayer helps to quickly get to the root cause by reproducing issues as if they happened in your own browser. It also monitors your frontend performance by capturing key metrics such as page load time, memory consumption and slow network requests as well as <em>Redux</em> actions/state.</p><p>Happy debugging, for modern frontend teams — <a href="https://asayer.io/register.html">Start monitoring your web app for free</a>.</p><h3>Comparing ecosystems</h3><p>With performance and API behind us, all that’s left to investigate is the ecosystem, community size, and documentation.</p><h4>Ecosystem and community</h4><p>In terms of ecosystem and community, it’s become clear that unless you’re React, Vue, or Angular, you are going to struggle. Although some recent trends push for framework-independence, these 3 UI frameworks, and especially React, still have strong backing in this regard.</p><p>Hyperapp isn’t an exception. It doesn’t have nearly as large a community and an ecosystem of a tiny fraction of React’s size. Again, this doesn’t at all mean that it’s useless.</p><p>The community, however small, is very committed and actively works on improving the framework. Hyperapp works beautifully with framework-independent tools, CSS frameworks, and a handful of <a href="https://github.com/jorgebucaran/hyperapp#packages">official</a> and <a href="https://github.com/jorgebucaran/hyperawesome">3rd-party</a> dedicated libraries available.</p><h3>Documentation</h3><p>Now, documentation is the go-to resource for starting with any framework or library.</p><p>React docs are really good — not perfect, but close. There’s a <a href="http://reactjs.org/">dedicated landing page</a>, detailed API docs and concept overviews, a full-blown introductory tutorial, and a community directory with useful links, of which there are tons and more unlisted.</p><p>As for Hyperapp, docs are surely not its strength. There’s no dedicated landing page (though <a href="https://github.com/jorgebucaran/hyperapp/pull/900">there was one</a> for <a href="https://github.com/jorgebucaran/hyperapp/issues/961#issuecomment-660227403">a brief period of time</a>), and limited documentation consisted of 2 Markdown files and a README file.</p><p>On the contrary, given Hyperapp’s simplicity, it could be argued it doesn’t need as much documentation as, e.g., React. The current one-page API docs and tutorial should be enough to give the developer a good understanding of the tool. There’s also some good <a href="https://github.com/jorgebucaran/hyperawesome">community-written content</a>.</p><p>At the time of writing, there’s an <a href="https://github.com/jorgebucaran/hyperapp/pull/1042">open PR</a> with a massive amount of new docs, so it’s worth keeping an eye on it.</p><h3>Summary</h3><p>So, to summarize this comparison, is Hyperapp a <em>“React killer”</em>? No, but it is a <strong>good alternative</strong> for those striving for simplicity, performance, or both. Those two are the primary focus of Hyperapp’s development.</p><p>The future looks bright for Hyperapp. Its most notable pitfalls, like JSX support, TypeScript typings, or good documentation, have <a href="https://github.com/jorgebucaran/hyperapp/pulls">opened PRs</a>. The framework is constantly being improved upon and has a <strong>clear goal</strong>.</p><p>So, if this comparison made you interested in Hyperapp, go <a href="https://github.com/jorgebucaran/hyperapp">check it out</a>!</p><p><em>Originally published at </em><a href="https://blog.asayer.io/hyperapp-is-it-the-lightweight-react-killer"><em>https://blog.asayer.io</em></a><em> on March 31, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff80a0fa3c61" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackanatomy/hyperapp-is-it-the-lightweight-react-killer-ff80a0fa3c61">Hyperapp — Is It the Lightweight ‘React Killer’?</a> was originally published in <a href="https://medium.com/stackanatomy">StackAnatomy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing end-to-end tests in 2021]]></title>
            <link>https://medium.com/stackanatomy/writing-end-to-end-tests-in-2021-48343c986e43?source=rss-de040aca1be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/48343c986e43</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <dc:creator><![CDATA[StackAnatomy Owner]]></dc:creator>
            <pubDate>Tue, 30 Mar 2021 00:00:00 GMT</pubDate>
            <atom:updated>2021-04-07T10:40:13.222Z</atom:updated>
            <content:encoded><![CDATA[<h4>Do you know where to start?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*azSM1YyGDGHsvk3s.png" /></figure><p>There’s no way around it — testing software is tedious. For the longest time, testing has been an unfortunate mix of brittle unit tests, stubbed integration tests, dubious smoke tests and manual verification regression tests that takes a day or two for a team of QA engineers to complete. And even with all of those tests passing, there is a real risk your app crashes anyway. So what is a developer to do?</p><p>Enter “end to end” testing. With a few articles like this one on board, you’ll write much less tests and have greater confidence in your code, all while making refactoring easier. Sounds too good to be true, right?</p><p>We will discuss what end to end tests are, what tests you should write, what tools to use and how to write your first few tests. In addition, we will make sure to summarize what not to do with end-to-end tests.</p><h3>What are end to end tests?</h3><p>End to end tests (or E2E tests for short) are tests that test your entire application flow, to make sure your entire application works as expected. Think of E2E tests as automated versions of real user interactions, where you tell the computer the same you would have told a test user to do.</p><p>These kinds of tests are extremely powerful, in that you can test large swaths of your application with only a few lines of code. Your test framework will spin up a regular or headless browser, load your application into memory and start interacting with it through click and keyboard events. This will give you confidence that if these tests pass, it will work for your users as well.</p><h3>What tests should you write?</h3><p>Even if this all sounds amazing, you should limit the amount of E2E tests you write. Since these tests spin up a real browser and interact with it, running them will be more resource intensive and slower than unit and integration tests. Therefore, you should focus your E2E testing on the main usage scenarios of your application.</p><p>Let’s look at an example restaurant review application. It requires authentication, and you can browse restaurants and review them. Here are the end to end tests I would have created for it:</p><ul><li>When unauthenticated, show login form, enter valid credentials, verify logged in</li><li>When unauthenticated, show login form, enter erroneous credentials, show error, verify not logged in</li><li>When authenticated, show list of restaurants, click one, verify reviews show up</li><li>When authenticated, go to restaurant, click add review, enter review, submit review, verify review shows up</li></ul><p>With these tests in place, and passing, I am pretty certain the core functionality of my application will work for my users. There might still be bugs, and edge cases I haven’t accounted for, but I can write integration tests or unit tests to make sure that code works as intended. The key is — I won’t have to write lots of those to have a high degree of trust!</p><h3>Setting up a modern E2E test rig</h3><p>End to end testing has been around for decades, but most of the tools available were made for enterprises and old windows machines. Names like Selenium and TestCafé comes to mind, and I have terrible experiences of flaky, slow and hard-to-maintain tests in both of them.</p><p>Luckily for us, there’s a new player in town. <a href="https://www.cypress.io/">Cypress</a> is a great tool that provides us with a modern solution for creating, running and maintaining code. Combined with <a href="https://testing-library.com/docs/cypress-testing-library/intro/">Cypress Testing Library</a> and the accessibility audit tool <a href="https://github.com/component-driven/cypress-axe">aXe</a>, you’ll have all the tools you need to gain confidence in your application, and to never deal with manual verifications in prod ever again.</p><p>To get started, we need to install some dependencies:</p><p>yarn add --dev cypress @testing-library/cypress cypress-axe</p><p>This command will — in addition to installing your dependencies- also create a cypress folder with a bit of boilerplate, and a cypress.json file you can use to specify some global settings. There isn&#39;t anything there by default, but we can add a base URL to avoid having to start every test with navigating to the same URL. Add the following to your cypress.json file:</p><p>Next, we want to include the helper methods from Cypress Testing Library and cypress-axe, so that we can use them in our tests. Navigate to the ./cypress/support/commands.js file, and add the following lines:</p><p>Finally, we’ll add two new scripts to our package.json to trigger test runs — one running a real browser and one running a headless one in your CI pipeline:</p><p>And with that, we’re ready to start writing tests!</p><h3>Writing tests</h3><p>Writing end to end tests are pretty similar to writing regular tests. We start off by creating a new file — ./cypress/integration/main-customer-flows.js , making a describe block, and injecting the accessibility plugin before each test.</p><p>We’re going to be using the global cy object to interact with Cypress.</p><p>This looks like pretty known territory for anyone who has ever written a unit test or two. Let’s write our first test — a test that checks the login functionality of our app.</p><p>We start the test by navigating to the login page, and ensuring there are no major accessibility errors in that view Any missing labels, inadequate color contrasts or other WCAG violations will be caught here — a great safety net in a single line of code.</p><p>We then find the input labeled by the text “Username”, and call the type method to type text into it - just like a user would. We do the same with the password field, and hit &quot;enter&quot;, logging the user in.</p><p>To ensure the login worked as expected, we make sure that the URL now includes “/profile” — the URL we redirect to after login. Finally, we ensure the profile view is accessible as well.</p><p>Let’s write another test for when the user types in the wrong credentials:</p><p>Here, we do the exact same test, but entering a different password. We assert that we’re still on the login page, and that we see an error indicating that the username or password was incorrect. We also ensure the page is accessible in this state as well.</p><p>This practice of verifying that the page is in an accessible state at every point in the user journey is one of my favorite things about end-to-end tests. It’s a thing that’s extremely time consuming to do manually, and incredibly valuable for both end users and your compliance department. You’ll still have to do some manual accessibility testing to be sure things work by the way.</p><p>I love how readable and straight forward these tests are. There are no scary test IDs to remember, no brittle element selectors, and it’s easy to understand what’s happening in a test by just looking at it.</p><h3>Bonus — Adding your own custom commands</h3><p>As you write more of these tests, you will probably write some pieces of logic several times over. Logging the user in to your app is one of those. Luckily, Cypress lets us specify our own custom commands to make our tests even more readable!</p><p>We define our custom command in our cypress/support/commands.js file:</p><p>This will make the cy.login(username, password) function available. Now we can refactor our tests a bit:</p><p>As your test suite grows in size and complexity, you might even want to avoid interacting with the UI at all for logging the user in. Instead, you can fire off HTTP requests to the server with the cy.request method. You can see an example of how this is implemented in the <a href="https://docs.cypress.io/api/cypress-api/custom-commands.html#Log-in-command-using-request">documentation</a>.</p><h3>Pitfalls</h3><p>End-to-end tests are great for a number of reasons, but they should not be the only way to verify your application.</p><p>As we mentioned at the outset, end-to-end tests are slow and resource intensive, which make them great to run before deploying your code, but not while developing or committing change. Instead, you can get a lot of the same benefits with regular integration tests. These don’t necessarily hit your backend system, and can be run in Node instead of in the browser. The end result is a much faster feedback loop, where you can test much more specialized scenarios than would be practically possible with end-to-end tests. Unit tests should also be a part of your testing suit, but should focus more on complex business logic than how your components render.</p><p>Therefore, I suggest you only create end-to-end tests for the main customer actions and business objectives of your app. This will make your tests run fast enough for you to actually run them, and they will function as the safety net they’re supposed to be.</p><h3>Frontend Application Monitoring</h3><p>A broken experience is not always due to an error or a crash, but maybe the consequence of a bug or a slowdown that went unnoticed. Did my last release introduce that? Is it coming from the backend or the frontend? Asayer helps answer those questions and figure out what part of your code requires fixing or optimization. Because inconsistent performance simply drives customers away, causing retention and revenues to drop.</p><p>As we embrace agility, we push code more frequently than ever, and despite our best testing efforts, our code may end up breaking for a variety of reasons. Besides, the frontend is different. It runs on different browsers, relies on complex JS frameworks, involves multiple CDN layers, gets affected by 3rd-party APIs, faulty internet connections, not-so-powerful devices, and slow backends. In fact, the frontend requires better visibility, and Asayer provides just that.</p><p>Your frontend is your business. It’s what people touch and feel. Let’s make it fast, reliable, and delightful!</p><p><a href="https://asayer.io/register.html">Start monitoring your web app for free</a>.</p><h3>Get to testing!</h3><p>End-to-end testing is an incredibly powerful and effective way to test your applications. You can verify that your app works as expected, and that there aren’t any major accessibility errors, all without validating a single thing by hand.</p><p>With tools like Cypress, Cypress Testing Library and cypress-axe, you’re ready to start writing end-to-end tests like a pro. Just remember not to go overboard with it!</p><p><em>Originally published at </em><a href="https://blog.asayer.io/writing-end-to-end-tests-in-2021"><em>https://blog.asayer.io</em></a><em> on March 30, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48343c986e43" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackanatomy/writing-end-to-end-tests-in-2021-48343c986e43">Writing end-to-end tests in 2021</a> was originally published in <a href="https://medium.com/stackanatomy">StackAnatomy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started With Open-Source]]></title>
            <link>https://medium.com/stackanatomy/getting-started-with-open-source-e34ef0029ee2?source=rss-de040aca1be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e34ef0029ee2</guid>
            <category><![CDATA[open-source-software]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[StackAnatomy Owner]]></dc:creator>
            <pubDate>Mon, 29 Mar 2021 00:00:00 GMT</pubDate>
            <atom:updated>2021-04-07T10:40:04.906Z</atom:updated>
            <content:encoded><![CDATA[<h4>How To Contribute</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y54kGXgNT_AIUoaQG6GSmg.png" /></figure><p>Contributing to open-source projects is a great way to improve your programming skills and contribute to the community. Also, it’s important to note that contributing to open-source projects is not all about coding. You can contribute in other ways. For example:</p><ul><li>Organise code</li><li>Write or improve the documentation</li><li>Design stuff</li><li>Review code</li></ul><p>Before going further, I advise you to read the code of conduct and the contribution guidelines. Please read them carefully before you start contributing because it explains what is expected from you. It also describes the workflow required to make contributions. The Open-Source guide has a great article on this subject — <a href="https://opensource.guide/code-of-conduct/">Your Code of Conduct</a>.</p><p>Are you ready to make your first contributions? Let’s do it!</p><h3>1. Find a project</h3><p>Finding a project to contribute to is a difficult task. I advise you to start small and pick a small project at first. Why? Things move faster in a small project, and it’s more likely to get your first contribution. But if you feel adventurous, you can start with a bigger project!</p><p>Moving further, there are a handful of useful websites which you can use to find projects and issues suited for beginners. Here is a non-exhaustive list:</p><ul><li>goodfirstissues.com — This website is great because it only contains issues that are suited for first time contributors; that is, for beginners. You can filter projects by programming language and repository.</li><li><a href="https://goodfirstissue.dev/">goodfirstissue.dev</a> — More or less, the same thing as the above website. Good First Issue curates easy pickings from popular open-source projects and helps you make your first contribution to open-source.</li><li>up-for-grabs.net — This website is a list of projects which have curated tasks specifically for new contributors.</li><li>github.com/explore — This is the explore page from Github itself. You can find lots of projects, but you have to search for issues suited for beginners manually.</li></ul><p>These websites should be more than enough to find a project. If not, you pick a tool that you use daily and contribute to that if it’s open-source.</p><h3>2. Basic Git workflow</h3><p>This article assumes basic knowledge of Git. The Git workflow you will be using is as follows:</p><ol><li>Fork the repository to your GitHub account.</li><li>Clone the project on your machine.</li><li>Create a branch before making changes.</li><li>Make your changes.</li><li>Commit and push your changes.</li><li>Open a pull request.</li></ol><p>The above workflow is the most basic one, and it’s enough to contribute to open source projects. It’s important to note that there are other variants, as well. However, you will use this one in the tutorial.</p><h3>3. Fork the project</h3><p>Let’s assume you found the perfect project to contribute. I will use the <a href="https://github.com/catalinpit/OSS-Contribution">OSS-Contribution</a> repository I created a while ago for this tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*unKiogVcsO78q1p7.png" /><figcaption><em>Figure 1</em></figcaption></figure><p>Go to the repository page, and click on the Fork button, as shown in figure 1 above!</p><p><strong>Why fork it first and not clone it directly?</strong> When you fork a project, you make a copy of it in your account. As a result, you can work on it without affecting the original repository. Forking creates a separate copy, whereas cloning downloads the project on your machine. Also, you cannot make changes to the repository if you only clone it. Only authorised people can make changes. By forking the project, you can make changes and submit pull requests.</p><p>After the forking is complete, it will redirect you to your copy of the project. Now it’s time to move onto the next step.</p><h3>4. Clone the project</h3><p>Now clone the project from your account. Go to the repository page to find the link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SKLox2W4RejJdDXQ.png" /><figcaption><em>Figure 2</em></figcaption></figure><p>To find the forked repository URL, click on the green button saying Code and copy the URL as shown in figure 2.</p><p>After copying the link, go to your terminal and run the following command <em>(replace the URL with yours)</em>:</p><p>Wait for the repository to download and then open it in your favourite code editor.</p><h3>5. Create a branch</h3><p>Before making any changes to the codebase, it’s important to create a new branch. Branches allow people to work on the project without getting into conflict with each other. Also, each branch is independent of others, so your branch’s changes are not visible in another branch (unless they are merged).</p><p>In the simplest words, your branch holds the changes you make to the project. Also, read the branch naming convention of each project. All projects specify how you should name your branches. Some examples are:</p><ul><li>your_name/issue_fix - E.g. catalinpit/add-name-768</li><li>issue_number-issue - E.g. ET182-Fix-broken-navbar</li></ul><p>Moving on, you can create a new branch and switch to it as follows:</p><p>Alternatively, you can do the same thing in one command as follows:</p><p>Now that you created a new branch, you are ready to make changes! Move onto the next section.</p><h3>6. Make changes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JxIP1UcF-tfLwiam.png" /><figcaption><em>Figure 3</em></figcaption></figure><p>The next step is to make changes in the repository. I cannot advise you about making changes because it depends on each repository.</p><p>However, using my Github example repository, I added a new Twitter account in the README file. Now you need to commit and push your changes, which you will do in the next step.</p><h3>7. Publish your changes</h3><p>The first step is to add all your changes to the staging area. Basically, the add command includes your updates from a particular file in the next commit. It specifies what &quot;to send to Github&quot;, in the simplest terms ever.</p><p>Run either of the following commands:</p><p>git add . adds all your changes to the staging area. For instance, if you made changes in 10 files, it adds all those files. On the other hand, you can handpick changes by specifying the file name, as in the second version above. It only includes the files you specify.</p><h4>Commit your changes</h4><p>You included the updates in the staging area, but now you have to commit them as well. Committing files means saving your updates to the local repository. Think of it as saving a Word document after making changes.</p><p>You can see the git commit command in action above. The `-m&#39; flag stands for &quot;message&quot;, and it allows you to summarise your changes. That means you should describe what you did in the project. Try to make the commit messages as concise and descriptive as possible. At the same time, it does not mean you should write a novel.</p><h4>Push your changes</h4><p>The last step is to “push” the changes to the remote repository. Until you “push” your changes, they are only available in your local repository. That is, nobody can see them except yourself.</p><p>To push your changes, run the following command:</p><p>You are almost done now! The next and last step is to create a Pull Request, which you’ll see in the next chapter.</p><h3>8. Open a pull request</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AuHq1BW7yqlNwNS8.png" /><figcaption><em>Figure 4</em></figcaption></figure><p>Suppose you followed all the steps from the seventh step — 7. Publish your changes - you should get a link in your terminal to open a pull request. Figure 4 (above) illustrates what you should see in your terminal.</p><p>If you do not get the same output for some reason, you can go to the repository URL &gt; Pull requests tab &gt; click on the Compare &amp; pull request. See figure 5 below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xuSbyR1Q7YCBl9SW.png" /><figcaption><em>Figure 5</em></figcaption></figure><p>Whatever option you choose, a new window should open where you can create the pull request. Figure 6 illustrates that!</p><p><strong>Be careful, though!</strong> Before submitting the pull request, make sure you read the contribution guidelines. At the minimum, add a descriptive title and description!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wI-kze7mdEG9SGdX.png" /><figcaption><em>Figure 6</em></figcaption></figure><p>Click on the green button saying Create pull request, and you are done! All you have to do is to wait for PR comments. Well done!</p><h4>Why do you need a PR?</h4><p>By opening a pull request, other people can see the changes you’ve made to the codebase. Additionally, it allows other members to do a code review, which in turn might help you improve your skills and code. Thus, you can get valuable feedback!</p><p>Also, some changes might not be approved for various reasons, such as:</p><ul><li>poor code quality</li><li>inefficient implementation … and many others.</li></ul><p>By creating pull requests, you protect the codebase from unwanted additions. Without pull requests, everyone can merge whatever they want to the main branch. Thus, the code quality will suffer.</p><p>In conclusion, pull requests helps and allows developers to:</p><ul><li>maintain a high-quality codebase</li><li>avoid introducing <em>(too many)</em> bugs <em>(because it can happen with PRs as well)</em></li><li>get feedback on the code</li><li>improve their skills and code</li></ul><h3>Frontend Monitoring</h3><p>Debugging a web application in production may be challenging and time consuming. Asayer is an open source frontend monitoring tool that replays everything your users do and shows how your app behaves for every issue. It’s like having your browser’s inspector open while looking over your user’s shoulder. Asayer lets you reproduce issues, aggregate JS errors and monitor your app’s performance. Asayer offers plugins for capturing the state of your <em>Redux or VueX</em> store and for inspecting <em>Fetch</em> requests and <em>GraphQL</em> queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QUvnFBXqPqwmkzZq.png" /></figure><p>Happy debugging, for modern frontend teams — <a href="https://asayer.io/register.html">Start monitoring your web app for free</a>.</p><h3>Conclusion</h3><p>Well done for learning the most basic Git workflow you can use to make OSS contributions. Also, well done for making your first open-source contribution if you followed the article!</p><p><em>Originally published at </em><a href="https://blog.asayer.io/getting-started-with-open-source-how-to-contribute"><em>https://blog.asayer.io</em></a><em> on March 29, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e34ef0029ee2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stackanatomy/getting-started-with-open-source-e34ef0029ee2">Getting Started With Open-Source</a> was originally published in <a href="https://medium.com/stackanatomy">StackAnatomy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>