<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ DIY - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ DIY - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Fri, 26 Jun 2026 22:48:11 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/diy/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ #LearnByDIY - How to create a JavaScript unit testing framework from scratch ]]>
                </title>
                <description>
                    <![CDATA[ By Alcides Queiroz I promise, this is gonna be fun. =) Probably, automated tests are part of your daily routine (if not, please stop reading this article and start from the beginning, by learning from the father of TDD himself). You’ve been using tes... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learnbydiy-how-to-create-a-javascript-unit-testing-framework-from-scratch-c94e0ba1c57a/</link>
                <guid isPermaLink="false">66c359f2f83dfae169b2c014</guid>
                
                    <category>
                        <![CDATA[ DIY ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Testing ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 09 Apr 2018 03:01:20 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*cedi3xCR8cINoPAje7Nrjw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Alcides Queiroz</p>
<p>I promise, this is gonna be fun. =)</p>
<p>Probably, automated tests are part of your daily routine (if not, please stop reading this article and <a target="_blank" href="https://www.amazon.com/Test-Driven-Development-By-Example/dp/0321146530">start from the beginning</a>, by learning from the father of TDD himself). You’ve been using testing frameworks such as <a target="_blank" href="https://www.node-tap.org/">Node-tap</a> (or <a target="_blank" href="https://github.com/substack/tape">Tape</a>), <a target="_blank" href="https://jasmine.github.io/">Jasmine</a>, <a target="_blank" href="https://mochajs.org/">Mocha</a> or <a target="_blank" href="https://qunitjs.com/">QUnit</a> for quite a while, just accepting that they do some magic stuff and not asking too many questions about them. Or, if you’re like me, maybe you’re always curious about how things work, including testing frameworks, of course.</p>
<p>This article will guide you through the process of creating a JavaScript testing framework from scratch, with a pretty decent DSL and a nicely detailed output. This is the first article in my <strong>#LearnByDIY</strong> series. The idea is to demystify certain kinds of software that we’re used to, by creating simpler versions of them.</p>
<h4 id="heading-disclaimers">Disclaimers</h4>
<p>Before starting, some important notes:</p>
<ul>
<li>The goal of this article is <strong>not</strong> to create a production-ready tool. Please, <strong>don’t use the framework that we’ll be creating to test production code.</strong> Its purpose is purely educational. =)</li>
<li>Naturally, our little framework won’t be full-featured. Things such as async tests, parallel executions, a richer set of matchers, a CLI (with options like <code>--watch</code>), pluggable reporters and DSLs, etc., won’t be present in our final version. However, I <strong>strongly recommend</strong> that you keep toying with this project and maybe try to <strong>implement some of these missing parts</strong>. Perhaps you can transform it into a serious open source project. I’d love to know that this toy project became an “actual” testing framework.</li>
</ul>
<h3 id="heading-tyrion-a-tiny-testing-framework">⚔️ Tyrion - A tiny testing framework</h3>
<p>Our framework will be tiny, but “brave” for its size. So, there’s no better name than Tyrion (yeap, he’s my favorite GoT character, too).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*cedi3xCR8cINoPAje7Nrjw.jpeg" alt="Image" width="590" height="427" loading="lazy">
<em>Tyrion is small, but brave.</em></p>
<p>We’ll be using Node.js in this project, with good and old CommonJS modules. The minimum Node version you’ll need is v8.6.0. If you have an older version, please update it.</p>
<p>Oh, I almost forgot… I’m using <a target="_blank" href="https://yarnpkg.com/lang/en/docs/install/">Yarn</a> throughout this article, for things like <code>yarn init</code>, <code>yarn link</code> and so on, but you can use “vanilla” NPM in a similar manner (<code>npm init</code>, <code>npm link</code>, …).</p>
<h4 id="heading-creating-the-project-folder-structure">Creating the project folder structure</h4>
<p>First, let’s create the following folder structure:</p>
<pre><code>tyrion/||______ proj/|      ||      |______ src/||______ playground/       |       |______ src/       |______ tests/
</code></pre><p>In other “words”:</p>
<pre><code>$ mkdir -p tyrion/proj/src tyrion/playground/src tyrion/playground/tests
</code></pre><p>We need two folders, each one to a separate project.</p>
<ul>
<li>The <code>proj</code> folder will contain the Tyrion framework package.</li>
<li>The <code>playground</code> folder will contain a disposable Node project for playing with our framework. It will serve as a lab during our development process.</li>
</ul>
<h4 id="heading-initializing-the-node-projects">Initializing the Node projects</h4>
<p>Go to the <code>playground</code> folder and run <code>yarn init -y</code>. This command generates a basic package.json file. Open it, remove the <code>"main": "index.js",</code> line, and add a “scripts” entry like the one in the example below:</p>
<pre><code>{  <span class="hljs-string">"name"</span>: <span class="hljs-string">"playground"</span>,  <span class="hljs-string">"version"</span>: <span class="hljs-string">"1.0.0"</span>,  <span class="hljs-string">"scripts"</span>: {    <span class="hljs-string">"test"</span>: <span class="hljs-string">"node tests"</span>  },  <span class="hljs-string">"license"</span>: <span class="hljs-string">"MIT"</span>}
</code></pre><p>After creating this file, let’s do the same for the other project, the Tyrion package itself. In the <code>proj</code> folder, run <code>yarn init</code>. It will prompt you for some information to properly create the package.json file. Enter the following values (in bold):</p>
<pre><code>question name (proj): tyrion &lt;enter&gt;question version (<span class="hljs-number">1.0</span><span class="hljs-number">.0</span>): &lt;enter&gt;question description: &lt;enter&gt;question entry point (index.js): src/index.js &lt;enter&gt;question repository url: &lt;enter&gt;question author: &lt;enter&gt;question license (MIT): &lt;enter&gt;question private: &lt;enter&gt;
</code></pre><p>Now, we need to install Tyrion as a development dependency in our playground project. If it was a published package, we’d just need to install it directly, through <code>npm i --dev</code> or <code>yarn add --dev</code>. As we only have Tyrion locally, this is not possible. Luckily, both Yarn and NPM have a feature to help developers during this package “inception” phase, allowing us to simulate a link between two packages (one as a dependency of the other).</p>
<p>To create this dependency link, go to the <code>proj</code> folder and run:</p>
<pre><code>$ yarn link
</code></pre><p>Then, in the <code>playground folder</code>, run:</p>
<pre><code>$ yarn link tyrion
</code></pre><p>That’s all. Now Tyrion is a dependency of the playground project.</p>
<h4 id="heading-creating-some-modules-to-be-our-guinea-pigs">Creating some modules to be our “guinea pigs”</h4>
<p>In the <code>playground/src</code> folder, let’s create two modules to be tested by Tyrion:</p>
<h4 id="heading-writing-some-tests">Writing some tests</h4>
<p>Now is the time to use our imagination. How should Tyrion’s DSL look? Are you sick of <code>expect</code>, <code>assert</code> , and so on? Let’s make it different, just for the fun of it. I suggest <code>guarantee</code> as our assertion function. Do you like it?</p>
<p>Let’s write a few tests to see it more clearly. Of course, nothing will work, since we didn’t implement anything in our framework.</p>
<p>And a <code>tests/index.js</code> file, to import our tests in only one place.</p>
<p>Tyrion will borrow one of Node-tap’s principles:</p>
<blockquote>
<p><strong>Test files should be “normal” programs that can be run directly.</strong></p>
<p>That means that it can’t require a special runner that puts magic functions into a global space. <code>node test.js</code> is a perfectly ok way to run a test, and it ought to function exactly the same as when it’s run by the fancy runner with reporting and such. JavaScript tests should be JavaScript programs; not english-language poems with weird punctuation.</p>
<p><a target="_blank" href="https://www.node-tap.org/#tutti-i-gusti-sono-gusti">https://www.node-tap.org/#tutti-i-gusti-sono-gusti</a>.</p>
</blockquote>
<p>As you might remember, in our playground’s package.json file, we have a <code>test</code> script which simply runs <code>node tests</code>. So, to execute it, just type <code>npm test</code> and hit enter. Yeap, do it. Let’s see it crashing:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*9h8lW-Kon3LuqlqQUI-0hA.png" alt="Image" width="800" height="284" loading="lazy"></p>
<p>This error is clear. We don’t have anything in our framework. No module is being exported at all. To fix it, in the <code>proj</code> folder, create a <code>src/index.js</code> file exporting an empty object, as you can see below:</p>
<pre><code><span class="hljs-built_in">module</span>.exports = {};
</code></pre><p>Now, we’ll run <code>npm test</code> again:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*ge5-uzTfUm-2bgrB8Gm3SQ.png" alt="Image" width="800" height="302" loading="lazy"></p>
<p>Node is complaining because our <code>guarantee</code> function doesn’t exist. This is simple to fix, too:</p>
<pre><code><span class="hljs-keyword">const</span> guarantee = <span class="hljs-function">() =&gt;</span> {};
</code></pre><pre><code><span class="hljs-built_in">module</span>.exports = { guarantee };
</code></pre><p>Run the test script again:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*ZNsFSHaRf8JWCRake1fTNw.png" alt="Image" width="698" height="85" loading="lazy"></p>
<p>Voilà! No errors, but nothing happens, either. =(</p>
<h4 id="heading-the-guarantee-function">The guarantee function</h4>
<p>Our assertion function should execute flawlessly if the supplied value is <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy"><em>truthy</em></a>, but should throw an error if it’s <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy"><em>falsy</em></a>.</p>
<p>Let’s implement it:</p>
<p>And to test if it works, let’s append another assertion to the end of our <code>number-utils.test.js</code> file:</p>
<pre><code>guarantee(<span class="hljs-number">123</span> === <span class="hljs-number">321</span>); <span class="hljs-comment">// This should fail</span>
</code></pre><p>Now run it once more:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*O8V_b4cKO7zxutYoLVuRdw.png" alt="Image" width="800" height="327" loading="lazy"></p>
<p>A-ha! It works! It’s ugly, but it’s functional.</p>
<h4 id="heading-the-check-function">The check function</h4>
<p>We need a way to wrap assertions into test units. Basically, all testing frameworks have this feature, like the <code>it</code> function in Jasmine or the <code>test</code> function in Node-tap.</p>
<p>In Tyrion, our test unit function will be called <code>check</code>. Its signature should be <code>check(testDescription, callback)</code>. We also want it to give us a friendlier output, describing the passing and failing tests.</p>
<p>This is what it will look like:</p>
<p>Now, we can rewrite our tests to use the new <code>check</code> function:</p>
<p>And re-run our test suite:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*CMuw0w6MzEfrKsyvR2QykQ.png" alt="Image" width="795" height="521" loading="lazy"></p>
<p>Cool. But… what about some colors?? Wouldn’t it be a lot easier to distinguish between passing and failing tests?</p>
<p>Add the <a target="_blank" href="https://www.npmjs.com/package/colors">colors</a> module as a dependency:</p>
<pre><code>yarn add colors
</code></pre><p>So, import it at the top of the <code>proj/src/index.js</code> file:</p>
<pre><code><span class="hljs-keyword">const</span> colors = <span class="hljs-built_in">require</span>(<span class="hljs-string">'colors'</span>);
</code></pre><p>And let’s put some colors in our output:</p>
<pre><code><span class="hljs-keyword">const</span> check = <span class="hljs-function">(<span class="hljs-params">title, cb</span>) =&gt;</span> {  <span class="hljs-keyword">try</span>{    cb();    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${<span class="hljs-string">' OK '</span>.bgGreen.black}</span> <span class="hljs-subst">${title.green}</span>`</span>);  } <span class="hljs-keyword">catch</span>(e) {    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${<span class="hljs-string">' FAIL '</span>.bgRed.black}</span> <span class="hljs-subst">${title.red}</span>`</span>);    <span class="hljs-built_in">console</span>.log(e.stack.red);  }};
</code></pre><p><img src="https://cdn-media-1.freecodecamp.org/images/1*D_Qp69Sx7kC5AfX2N9nfzg.png" alt="Image" width="800" height="409" loading="lazy"></p>
<p>That’s better. =)</p>
<h4 id="heading-the-xcheck-function">The xcheck function</h4>
<p>It would be nice to have an easy way to disable a specific test, like the <code>xit</code> function in Jasmine. This can be easily implemented by creating a no-op function which just outputs that a test is disabled (well, it’s not completely no-op, but almost):</p>
<pre><code><span class="hljs-keyword">const</span> xcheck = <span class="hljs-function">(<span class="hljs-params">title, cb</span>) =&gt;</span> {  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${<span class="hljs-string">' DISABLED '</span>.bgWhite.black}</span> <span class="hljs-subst">${title.gray}</span>`</span>);};
</code></pre><pre><code><span class="hljs-built_in">module</span>.exports = { guarantee, check, xcheck };
</code></pre><p>So, import the <code>xcheck</code> function in the <code>number-utils.test.js</code> file and disable one of our tests:</p>
<pre><code><span class="hljs-keyword">const</span> { guarantee, check, xcheck } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'tyrion'</span>);<span class="hljs-keyword">const</span> numberUtils = <span class="hljs-built_in">require</span>(<span class="hljs-string">'../src/number-utils'</span>);
</code></pre><pre><code><span class="hljs-comment">// method: isPrimexcheck('returns true for prime numbers', () =&gt; {  guarantee(numberUtils.isPrime(2));  guarantee(numberUtils.isPrime(3));  guarantee(numberUtils.isPrime(5));  guarantee(numberUtils.isPrime(7));  guarantee(numberUtils.isPrime(23));});</span>
</code></pre><p>And here’s how it behaves:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*kSCPsNlejl9OdZC8VUruyw.png" alt="Image" width="800" height="386" loading="lazy"></p>
<h4 id="heading-test-summary-and-exit-code">Test summary and exit code</h4>
<p>If we wanted to use Tyrion in a CI server, it would need to finish its process with different exit codes for error and success conditions.</p>
<p>Another desirable feature is a test summary. It would be nice to know how many tests passed, failed, or skipped (the disabled ones). For this, we could increment some counters in both <code>check</code> and <code>xcheck</code> functions.</p>
<p>We will create the <code>end</code> function, which prints the test summary and finishes with the appropriate exit code:</p>
<p>And don’t forget to call it in the <code>playground/tests/index.js</code> file:</p>
<pre><code><span class="hljs-keyword">const</span> { end } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'tyrion'</span>);
</code></pre><pre><code><span class="hljs-built_in">require</span>(<span class="hljs-string">'./string-utils.test'</span>);<span class="hljs-built_in">require</span>(<span class="hljs-string">'./number-utils.test'</span>);
</code></pre><pre><code>end();
</code></pre><p>Or maybe:</p>
<pre><code><span class="hljs-keyword">const</span> tyrion = <span class="hljs-built_in">require</span>(<span class="hljs-string">'tyrion'</span>);
</code></pre><pre><code><span class="hljs-built_in">require</span>(<span class="hljs-string">'./string-utils.test'</span>);<span class="hljs-built_in">require</span>(<span class="hljs-string">'./number-utils.test'</span>);
</code></pre><pre><code>tyrion.end();
</code></pre><p>Now, let’s re-run <code>npm test</code>:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*MK7W8WxuDSD6grErVrSZKA.png" alt="Image" width="800" height="544" loading="lazy"></p>
<p>Great, it works.</p>
<h4 id="heading-the-group-function">The group function</h4>
<p>Many test frameworks have some way of grouping related tests. In Jasmine, for example, there is the <code>describe</code> function. We will implement a <code>group</code> function for this purpose:</p>
<p>And update our tests to use this new function:</p>
<p>Here’s the new output:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*8y2171rDoHbOhGMIt3myGw.png" alt="Image" width="800" height="717" loading="lazy"></p>
<p>Well, the good news is that it works. The bad news is that it’s getting hard to understand. We need a way to indent this output in order to make it more readable:</p>
<p>Run it again:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*X1QQ7GuihVzZkFS6yQ91Jg.png" alt="Image" width="800" height="679" loading="lazy"></p>
<p>That’s way better!</p>
<p>So, how does it work?</p>
<ul>
<li>The <code>repeat</code> function repeats a string <code>n</code> times.</li>
<li>The <code>indent</code> function repeats an indent (of four spaces) <code>n</code> times by using the <code>repeat</code> function.</li>
<li>The <code>indentLines</code> function indents a string with multiple lines by adding <code>n</code> indents to the beginning of each line. We’re using it to indent error stacks.</li>
<li>The <code>indentLevel</code> variable is incremented at the beginning of each group execution and decremented at its end. This way, nested groups can be correctly indented.</li>
</ul>
<h4 id="heading-more-matchers">More matchers</h4>
<p>The <code>guarantee</code> function is not flexible enough for a lot of scenarios. We need a richer set of matchers in order to make our tests more meaningful.</p>
<p>First, create the <code>matchers</code> folder:</p>
<pre><code>$ mkdir proj/src/matchers
</code></pre><p>Now, we’ll create each matcher in a separate file:</p>
<p>The <code>same</code> matcher uses the strict equality operator (===) to test if two arguments are exactly the same object (for reference types) or equal (for primitive types). It behaves similarly to the <code>toBe</code> matcher in Jasmine and <code>t.equal</code> in node-tap.</p>
<p><strong>Note:</strong> Node-tap also has a matcher called <code>t.same</code>, but it works differently (it won’t verify if two objects are exactly the same, but if both are deeply equivalent).</p>
<p>The <code>identical</code> matcher verifies that two arguments are equivalent. It uses the <code>==</code> operator for comparing values.</p>
<p>The <code>deeplyIdentical</code> matcher does a deep comparison of two objects. This kind of comparison can be considerably complex, or at least too complex for this article’s purpose. So, let’s install an existing module to handle deep equality and use it in our matcher:</p>
<pre><code>$ yarn add deep-equal
</code></pre><p>Then:</p>
<p>This is how an error will look:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*P3SI0UMJlXOusnB0A9yrNw.png" alt="Image" width="800" height="892" loading="lazy"></p>
<p>The <code>falsy</code> matcher will fail if the supplied value is truthy.</p>
<p>The <code>truthy</code> matcher works in a similar manner to our <code>guarantee</code> function. It passes when the supplied value is truthy and breaks if it’s falsy.</p>
<p>The <code>throws</code> matcher will pass if a function throws an error. It’s possible to specify the wanted error message, but this is not mandatory.</p>
<p>An <code>index.js</code> file to re-export all matchers:</p>
<p>And finally let’s glue them all together:</p>
<p>You can use our new matchers this way:</p>
<pre><code><span class="hljs-keyword">const</span> { guarantee, check } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'tyrion'</span>);
</code></pre><pre><code>check(<span class="hljs-string">'playing with our new matchers'</span>, <span class="hljs-function">() =&gt;</span> {  <span class="hljs-comment">// The original guarantee function still works  guarantee(123 === 123);</span>
</code></pre><pre><code>  guarantee.truthy(<span class="hljs-string">'abc'</span>);  guarantee.falsy(<span class="hljs-literal">null</span>);
</code></pre><pre><code>  <span class="hljs-keyword">const</span> a = { <span class="hljs-attr">whatever</span>: <span class="hljs-number">777</span> };  <span class="hljs-keyword">const</span> b = a;  guarantee.same(a, b);  guarantee.identical(<span class="hljs-literal">undefined</span>, <span class="hljs-literal">null</span>);
</code></pre><pre><code>  <span class="hljs-keyword">const</span> c = { <span class="hljs-attr">whatever</span>: { <span class="hljs-attr">foo</span>: { <span class="hljs-attr">bar</span>: <span class="hljs-string">'baz'</span> } } };  <span class="hljs-keyword">const</span> d = <span class="hljs-built_in">Object</span>.assign({}, c);  guarantee.deeplyIdentical(c, d);
</code></pre><pre><code>  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">boom</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'Some error...'</span>); }  guarantee.throws(boom);  guarantee.throws(boom, <span class="hljs-string">'Some error...'</span>);});
</code></pre><h4 id="heading-the-beforeeach-function">The beforeEach function</h4>
<p>To implement a <code>beforeEach</code> function, we need to use a stack to accumulate all <code>beforEach</code> callbacks. This is done for each new scoped level created every time a group is declared:</p>
<p>How does it work?</p>
<ul>
<li>Every time a group is declared, we’re pushing a new array to the <code>beforeEachStack</code> variable. This array will accumulate all <code>beforeEach</code> callbacks declared in that scope.</li>
<li>After a group execution is completed, we remove the array at the top of our callbacks stack.</li>
<li>The <code>beforeEach</code> function receives a callback and appends it to the array at the top of our callbacks stack.</li>
<li>At the beginning of each <code>check</code> function, we’re calling every <code>beforeEach</code> callback in all levels of our stack.</li>
</ul>
<h4 id="heading-the-beforeall-function">The beforeAll function</h4>
<p>Our last addition will be the <code>beforeAll</code> function. <strong>For simplicity’s sake</strong>, we’re assuming that calls to the <code>beforeAll</code> function will always be put before all groups and tests (<strong>or</strong>, when scoped within a group, at its very top).</p>
<p>Otherwise, if we wanted to ensure that the <code>beforeAll</code> function works correctly even in the middle or at the end of a group, we should dramatically change our existing logic. Well, we’re not going to do that, since it isn’t a rational usage of this function.</p>
<p>Our version of <code>beforeAll</code> will just receive a callback and immediately execute it.</p>
<pre><code><span class="hljs-keyword">const</span> beforeAll = <span class="hljs-function"><span class="hljs-params">cb</span> =&gt;</span> cb();
</code></pre><pre><code><span class="hljs-built_in">module</span>.exports = {   group, check, xcheck, guarantee, beforeAll, end };
</code></pre><p>An example of usage:</p>
<pre><code><span class="hljs-keyword">const</span> { guarantee, check, group, beforeAll } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'tyrion'</span>);
</code></pre><pre><code><span class="hljs-keyword">let</span> a;beforeAll(<span class="hljs-function">() =&gt;</span> {  a = { <span class="hljs-attr">something</span>: <span class="hljs-string">'example'</span> };});
</code></pre><pre><code>group(<span class="hljs-string">'playing with the beforeAll function'</span>, <span class="hljs-function">() =&gt;</span> {  <span class="hljs-keyword">let</span> b;  beforeAll(<span class="hljs-function">() =&gt;</span> {    b = { <span class="hljs-attr">something</span>: <span class="hljs-string">'example'</span> };  });
</code></pre><pre><code>  check(<span class="hljs-string">'some test'</span>, <span class="hljs-function">() =&gt;</span> {    guarantee.deeplyIdentical(a, b);  });
</code></pre><pre><code>  check(<span class="hljs-string">'another test'</span>, <span class="hljs-function">() =&gt;</span> {    guarantee.identical(<span class="hljs-number">11</span>, <span class="hljs-number">11</span>);  });});
</code></pre><h4 id="heading-the-final-version-of-tyrion">The final version of Tyrion</h4>
<p>It has been a long journey, but Tyrion is finally complete. =)</p>
<p>I added a SILENT option which disables logging. It’s being used to make it easier to test Tyrion (yep, testing frameworks need to be tested too).</p>
<p>The complete project is available <a target="_blank" href="https://www.github.com/alcidesqueiroz/tyrion">here</a>.</p>
<h4 id="heading-possible-improvements">Possible improvements</h4>
<p>Tyrion lacks many features, like:</p>
<ul>
<li>Support for async tests</li>
<li>Parallel execution of tests</li>
<li><code>afterEach</code> and <code>afterAll</code> functions</li>
<li>A <code>xgroup</code> function, which disables an entire group</li>
<li>A function similar to <a target="_blank" href="https://jasmine.github.io/api/edge/global.html#fit">Jasmine’s fit</a></li>
<li>Spies</li>
<li>Decoupling DSL from reporting logic.</li>
<li>Pluggable reporters</li>
<li>A terminal CLI (with a <code>--watch</code> option)</li>
<li>Yet more matchers</li>
<li>Friendlier error stacks</li>
</ul>
<p>I encourage you to keep playing with this project. Feel free to use and expand it. Please let me know your thoughts, suggestions, and experiments by leaving a comment below. =)</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Create an Arduino and Unity3D interactive experience with no latency !⏱ ]]>
                </title>
                <description>
                    <![CDATA[ By Maxime Coutte Hi, I’m 16 years old and during the holidays I like to work on little projects. I grew up in a very artistic environment - my father is a painter my brothers and sisters draw, play music, compose … And me, with my best friend we want... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/you-can-now-create-an-arduino-and-unity3d-interactive-experience-without-latency-2d7388dcc0c/</link>
                <guid isPermaLink="false">66c367c69aa4fb7920cb7dde</guid>
                
                    <category>
                        <![CDATA[ arduino ]]>
                    </category>
                
                    <category>
                        <![CDATA[ DIY ]]>
                    </category>
                
                    <category>
                        <![CDATA[ open source ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Unity3D ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 16 Dec 2017 13:35:22 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*GYnriIV-IBFyGDDIHjbQBA.gif" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Maxime Coutte</p>
<p>Hi, I’m 16 years old and during the holidays I like to work on little projects. I grew up in a very artistic environment - my father is a painter my brothers and sisters draw, play music, compose … And me, with my best friend we wanted to have fun with our new Arduino and Unity3D, so we started working on interactive artistic experiences. But we got stuck on one big thing. If you’ve ever wanted to transmit data from Arduino to Unity3D, you know the main issue is <strong>INSANE LATENCY</strong>.</p>
<h4 id="heading-dont-worry-about-latency-wrmhlhttpsgithubcomrelativtywrmhl-is-here">Don’t worry about Latency, <a target="_blank" href="https://github.com/relativty/wrmhl">wrmhl</a> is here ⚡️</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Eq8d7WJ-2ZRuoAtYB-3UtzLDkFKivnwklyUc" alt="Image" width="480" height="320" loading="lazy">
<em>Without wrmhl (using a simple ReadLine () )</em></p>
<p>We didn't find any free, optimized, and customizable solutions to tackle this problem. So I built <a target="_blank" href="https://github.com/relativty/wrmhl"><strong>wmrhl</strong></a>. You can now connect any Arduino interface to Unity3D, and it’s completly <strong>Open Source.</strong></p>
<ul>
<li>Just write your Arduino code, how about <a target="_blank" href="https://www.youtube.com/watch?v=ikD_3Vemkf0">A Touchless 3D Tracking Interface</a> or a <a target="_blank" href="http://openbci.com/">Brain-Computer Arduino Interface</a> ?</li>
<li>Add a Serial print to send data from your interface to Unity3D (<a target="_blank" href="https://github.com/relativty/wrmhl/blob/master/Arduino/Arduino.ino">see examples</a>)</li>
<li>Import wrmhl to Unity, and voilà!</li>
</ul>
<p>You can use the default wrmhl protocol, or implement your own in a minute just by changing: <a target="_blank" href="https://github.com/relativty/wrmhl/blob/master/Assets/WRMHL/Scripts/Thread/wrmhlThread_Lines.cs">wrmhl/Assets/WRMHL/Scripts/Thread/wrmhlThread_Lines.cs</a>.</p>
<h4 id="heading-how-to-get-started">How to get started ?</h4>
<p>just follow the guide by <a target="_blank" href="https://github.com/relativty/wrmhl#getting-started-%EF%B8%8F"><strong>clicking here</strong></a>. Star the repo if you liked it ⭐️</p>
<p>Hope this is helpful! If you’re using it, would love to hear about what you’re building. Ping me at <strong>maxime@relativty.com</strong> or <a target="_blank" href="https://twitter.com/maximecoutte">@maximecoutte</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
