<?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: Artur</title>
    <description>The latest articles on DEV Community by Artur (@dachia).</description>
    <link>https://dev.to/dachia</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1164848%2Fe792c506-4214-40e3-90b7-451874b79e23.png</url>
      <title>DEV Community: Artur</title>
      <link>https://dev.to/dachia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dachia"/>
    <language>en</language>
    <item>
      <title>Choosing JS test framework in 2023</title>
      <dc:creator>Artur</dc:creator>
      <pubDate>Wed, 20 Sep 2023 07:18:18 +0000</pubDate>
      <link>https://dev.to/dachia/choosing-js-test-framework-in-2023-428n</link>
      <guid>https://dev.to/dachia/choosing-js-test-framework-in-2023-428n</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/dachia/starting-typescript-project-in-2023-5bj6"&gt;In my previous post&lt;/a&gt; I went through the process of bootstrapping the typescript project, choosing runtime, and thinking of important stuff.&lt;br&gt;
I wrote a simple filter function to work with API responses in my newly created 2023 typescript project 😉 . My thoughts were:&lt;/p&gt;

&lt;p&gt;To run the project, generate some data, and test the function live.&lt;br&gt;
What if it doesn't work the first time(very likely)?&lt;br&gt;
I thought about how many iterations it would take to fix it and how much time I would lose by manually running live tests every time. And then I remembered: unit tests are fast. Sure upfront cost of choosing a framework, and bootstrapping it will be slower than testing it manually a couple of times, but I will have it set up for later and will ensure that the function works after code changes, and in general cultivates better habits for myself(those are important).&lt;/p&gt;

&lt;h2&gt;
  
  
  So which framework for unit tests?
&lt;/h2&gt;

&lt;p&gt;Choices are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Jasmine&lt;/li&gt;
&lt;li&gt;Jest&lt;/li&gt;
&lt;li&gt;Mocha&lt;/li&gt;
&lt;li&gt;AVA&lt;/li&gt;
&lt;li&gt;Tape&lt;/li&gt;
&lt;li&gt;builtin bun test runner(compatible with jest)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Jasmine and Jest
&lt;/h3&gt;

&lt;p&gt;are IMHO test frameworks for angular and react.&lt;br&gt;
Comes with the battery included, meaning almost no setup required. Both depend on globals, which, in my book, is bad if you can't refrain from sharing state between tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mocha
&lt;/h3&gt;

&lt;p&gt;is good, the most popular, very old(12+ years), and mature framework.&lt;br&gt;
Very modular, depends on globals. Will have to install something for assertions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why AVA
&lt;/h3&gt;

&lt;p&gt;in their own words:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minimal and fast&lt;/li&gt;
&lt;li&gt;Simple test syntax&lt;/li&gt;
&lt;li&gt;Runs tests concurrently&lt;/li&gt;
&lt;li&gt;Enforces writing atomic tests&lt;/li&gt;
&lt;li&gt;No implicit globals&lt;/li&gt;
&lt;li&gt;Includes TypeScript definitions&lt;/li&gt;
&lt;li&gt;Magic assert&lt;/li&gt;
&lt;li&gt;Isolated environment for each test file&lt;/li&gt;
&lt;li&gt;Promise support&lt;/li&gt;
&lt;li&gt;Async function support&lt;/li&gt;
&lt;li&gt;Observable support&lt;/li&gt;
&lt;li&gt;Enhanced assertion messages&lt;/li&gt;
&lt;li&gt;Automatic parallel test runs in CI&lt;/li&gt;
&lt;li&gt;TAP reporter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list got me slightly giddy. 20k start on github, not bad. Also, &lt;strong&gt;The only one that supports Ukraine openly.&lt;/strong&gt; 👍&lt;/p&gt;

&lt;h3&gt;
  
  
  Tape
&lt;/h3&gt;

&lt;p&gt;Minimal, opinionated, no globals, no setup functions... honestly I am already biased towards AVA. &lt;em&gt;I just can't stop thinking of AVA.&lt;/em&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Builtin bun test runner
&lt;/h3&gt;

&lt;p&gt;Bun ships with a fast, built-in, Jest-compatible test runner. Tests are executed with the Bun runtime. Jest, but it's bun, and not ts-node. Enough said.&lt;/p&gt;

&lt;h2&gt;
  
  
  Experiments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Trying AVA 💔
&lt;/h3&gt;

&lt;p&gt;Yeah, so I couldn't make AVA use bun, and using ts-node is slow(3 sec for a single test, are you serious?), which goes against the reason why I chose bun in the first place. So sorry AVA 😢, I wanted this to work out badly, but life is life.&lt;/p&gt;

&lt;h3&gt;
  
  
  Going with bun test ❤️
&lt;/h3&gt;

&lt;p&gt;Since it's compatible with jest, we can always fall back to jest. Fast, don't have anything else to add. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Wanted to go with AVA badly, even if based on subjective opinion.&lt;/p&gt;

&lt;p&gt;But oh well, jest compatible bun test runner it is :) So basically jest it is. Just because it's easier, faster, and would work out of the box. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next post coming soon...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Subscribe, react, and share, if you liked this. &lt;br&gt;
Also, If you have an opinion, I would love to hear it down in the comments.&lt;/em&gt;&lt;br&gt;
👋&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Starting typescript project in 2023</title>
      <dc:creator>Artur</dc:creator>
      <pubDate>Tue, 19 Sep 2023 06:36:47 +0000</pubDate>
      <link>https://dev.to/dachia/starting-typescript-project-in-2023-5bj6</link>
      <guid>https://dev.to/dachia/starting-typescript-project-in-2023-5bj6</guid>
      <description>&lt;p&gt;It's that time of the year when you are creating a new repo for some reason and the choice is to typescript or not to typescript. &lt;br&gt;
You decided to typescript.&lt;br&gt;
Now you start wondering, what has changed? Did the industry move? Are there better tools to add typescript(since 2022 when you did it last)? What's the fastest typescript compiler? How to make sure intelligence isn't as slow as that one project with tens of thousands of code lines, a mix of ts and js and god knows what else?&lt;br&gt;
Since all I found were those articles express and typescript in 2023 where they would install additional dependency express typescript which would then get discontinued in 2024 and you will be left on your own. IDK about you, but that's not how I do things.&lt;br&gt;&lt;br&gt;
I like to overcomplicate things.&lt;br&gt;
First things first, what runtime?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;node.js&lt;/li&gt;
&lt;li&gt;deno&lt;/li&gt;
&lt;li&gt;bun&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since I am chaos incarnate, and I also like to think about the future a bit, I chose to try bun. Why? It seems like it's striving to have maximum compatibility and in the end I can switch back to node.js + ts-node, or some such.&lt;/p&gt;

&lt;p&gt;Install bun&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL https://bun.sh/install | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Init project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;oh, nice! it generated tsconfig. And I was contemplating writing a huge post on how to have fun and nonintrusive yet good enough tsconfig.&lt;/p&gt;

&lt;p&gt;OK! The goal is to write a CLI tool to create fixtures for e2e tests. &lt;br&gt;
I want to it be versatile. In real-life processes, users use mobile apps to enter data. But we are not going to use UI automation tool like Apium just yet, instead, i am going to add an abstraction(so that we can switch to UI automation framework later).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next post coming soon...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Subscribe, react, and share, if you liked this. &lt;br&gt;
Also, If you have an opinion, I would love to hear it down in the comments.&lt;/em&gt;&lt;br&gt;
👋&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>typescript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
