<?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 Sebastian Hines on Medium]]></title>
        <description><![CDATA[Stories by Sebastian Hines on Medium]]></description>
        <link>https://medium.com/@dkzeb?source=rss-a71bbd219bed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DOcMXVnclSV-Cjc7AclkRA.jpeg</url>
            <title>Stories by Sebastian Hines on Medium</title>
            <link>https://medium.com/@dkzeb?source=rss-a71bbd219bed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:29:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dkzeb/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[Why i don’t think React is necessary]]></title>
            <link>https://dkzeb.medium.com/why-i-dont-think-react-is-necessary-cbeedbe556f?source=rss-a71bbd219bed------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbeedbe556f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[framework-wars]]></category>
            <dc:creator><![CDATA[Sebastian Hines]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 19:13:13 GMT</pubDate>
            <atom:updated>2021-09-07T19:16:37.914Z</atom:updated>
            <content:encoded><![CDATA[<p>This is going to be my very opinionated, somewhat ranting write-up of why i don’t think React has a place in the world of front-end frameworks, why i personally hate it — and why i prefer either Vue or Angular instead.</p><p>This is not, as such, intended to tell you or anybody else that they should not use React. I know people love it, it has a bigger community than Angular, it’s backed by Facebook and i know that it will continue to be used again and again in many projects to come.</p><h3>The lay of the (framework) land</h3><p>As a professional developer, utilizing javascript for all sorts of development, the land of frameworks is sparse and dominated by the three big frameworks of our time; <em>Angular</em>, <em>React </em>and <em>Vue.</em></p><p>Every tool has it’s purpose, and for me as a developer i tend to develop two types of web-applications; minor “applet” style apps — such as a reactive form on a static webpage or maybe even updating a legacy site, piece by piece. This is what Vue was made for — and it works very well.</p><p>The other type of application are large enterprise style web applications. Now im sure React is perfect for any job you want to use it for — that’s pretty much what i keep being told, however — my own experiences have shown me that every React project is different. There are no clear guidelines or conventions when writing code and if there is — it is community taught and not something that comes natural to me as a corporate developer. This means i have seen countless React projects that approach things differently — in the company at which i work we have many, many projects (we are an ok sized comany at about 3500 people) that use React — they all start from scratch and all approach things differently.</p><h4>Why Angular is better than React (in my humble opinion)</h4><p>So — here is the extremely black/white super opinionated take on this.</p><p>While i have seen as many Angular projects, as React — that approach things differently — the structure for the Angular projects are enforced by the boilerplate generated by the CLI as well as the way Angular is made to be used. I read somewhere once that</p><blockquote>You can do anything in Angular, you just have to do it the Angular way</blockquote><p>This. This might be offputing to some. Conventions being forced upon you, but for me, as a developer that typically takes part in smaller or larger teams. This is gold. This guarantees at least SOME sense of consitency when dealing with multiple projects based on Angular. Say i come to a new project, i am asked to clear up several bugs in the front-end and develop a new feature. Because Angular forces a particular structure and code style. It will not take me a long time to get up to speed on this particular project — and i can spend my time dealing with domain-specific issues instead of tooling and framework — because we also follow the Angular way — Handover of our projects to other developers or client in-house teams tend to go smoothly — the general structure is known before hand.</p><p>On the other hand, most React projects i have seen follows the structural principle of; <em>“who-ever was in charge that day“</em> — this might not be an issue in smaller companies with 2 or 3 dev teams — but trust me, in a large corporation — many many hours are wasted dealing with these issues.</p><p>Also, setting up shared code libraries is a breeze and, if you DO follow the Angular way — creating components that can basically drag and drop between projects becomes quite easy.</p><h3>In conclusion</h3><p>Every tool has its trade — but i do not see what particular problem React solves. Vue is by far the easier of the two when it comes to implementing a gradual transition of a legacy website or small webcomponents. Angular is superior to React in its enforced structure — for me at least — when it comes to enterprise applications.</p><p>Agree, or agree to disagree? :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbeedbe556f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit Testing in ts-jest with TypeOrm entities]]></title>
            <link>https://dkzeb.medium.com/unit-testing-in-ts-jest-with-typeorm-entities-ad5de5f95438?source=rss-a71bbd219bed------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad5de5f95438</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[typeorm]]></category>
            <category><![CDATA[ts-jest]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sebastian Hines]]></dc:creator>
            <pubDate>Sat, 04 Sep 2021 21:54:38 GMT</pubDate>
            <atom:updated>2021-09-04T21:54:38.475Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTJj_q7zBUN5DsnE_Wf0JA.jpeg" /></figure><p>For a long time i have been using TypeOrm in my projects, but … i am ashamed to admit — i have not really been writing unit tests when the unit in question was using TypeOrm entities. Its not that i dont want to — its that i didnt really have a good clean way of doing it. I had tried many different approaches, from using Jasmine to mock the typeorm components to just allowing the unit test to create entities in my development db and then cleaning it up afterwards — in the end i just stopped writing the unit-tests.</p><p>I checked around for documentation or examples on how to do this but found it either lacking or dripping with opinionated discussions on whether or not what was being done was propper.</p><p>However, i finally think i found what i would consider a proper way of doing this, which entails using an sqlite in-memory database to act as a test/mock database connection — follow along to learn how to do this yourself (or judge me and tell me im wrong ;) )</p><h3>The how to</h3><p>Lets look at how you too can use this approach to unit-test your code with TypeOrm.</p><p>The idea is to create an in-memory sqlite database that we can setup when the test starts and tear down after the test</p><h4>Prerequisites</h4><p>To do this we are going to use the following npm packages</p><ul><li>Typescript (must be installed locally for ts-jest to work)</li><li>Jest and ts-jest (ts-jest depends on jest)</li><li>TypeOrm (duh)</li><li>Better-SQLite3 (for the test db)</li></ul><pre>npm install --save typeorm<br>npm install --save-dev typescript jest ts-jest @types/ts-jest better-sqlite3 @types/better-sqlite3</pre><p>Note that most of what we are installing is developer dependencies, so we dont clutter production with the packages we need for testing</p><p>We then setup a typescript project (im not gonna tell you how to do this — it differs a lot what people prefer, i typically go for something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*oick_-9SGqv1z2c3p-1Hlw.png" /><figcaption>My typical typescript / nodejs folder structure</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*rsIKmbGnE7UOrI0t4dvmOA.png" /><figcaption>testhelper.ts in the tests folder</figcaption></figure><h4>TestHelper</h4><p>To handle the database connection (and to simplify what we need to import in our spec files) we create a TestHelper singleton class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/618f8cb34dd1410597e53b2cb28673ef/href">https://medium.com/media/618f8cb34dd1410597e53b2cb28673ef/href</a></iframe><p>So lets just do a quick walkthrough here; standard singleton pattern, and two methods, the async <em>setupTestDB() </em>and the <em>teardownTestDB()</em></p><p>As we can see, we create a new <em>sqlite3</em> database (note that we are using <em>better-sqlite3</em> instead of just <em>node-sqlite3 </em>— why? read here: <a href="https://www.npmjs.com/package/better-sqlite3">https://www.npmjs.com/package/better-sqlite3</a>)</p><p>This sqlite database is then referenced in the TypeOrm createConnection connection options. These options also point at the src/entity folder to allow this test connection to see our entities, and has <em>synchronize: true</em> so that our entities are synced everytime we run the tests.</p><h4>In-use example</h4><p>So, now we have a helper class that creates a typeorm database connection for us, how to use it?</p><p>Lets say we have the following code</p><p>A typeorm entity, <em>NumberMap</em> which stores a relation between a phonenumber and a home property</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f60229f78a3baf9a5271f06dc43e41e6/href">https://medium.com/media/f60229f78a3baf9a5271f06dc43e41e6/href</a></iframe><p>And the following Gateway class that manages these mappings</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74b6392c5f515cf8ff1f6f8f53e0cf2c/href">https://medium.com/media/74b6392c5f515cf8ff1f6f8f53e0cf2c/href</a></iframe><p>We can then do a <em>gateway.spec.ts </em>file with the following code to test these two methods</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c886d3f4c135755f73aafaed0edf186/href">https://medium.com/media/0c886d3f4c135755f73aafaed0edf186/href</a></iframe><p>So using lifecycle methods of jest, <em>beforeAll</em> and <em>afterAll </em>we can create the connection to our in-memory typeorm database — which will then be active during the entire test suite (note how this allows us to test creation of an entity in one test and then consumption of this entity in a separate test)</p><p>So — using the above i have now begun writing unit tests for all parts of my backend applications — and i hope you can too :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad5de5f95438" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>