<?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 Danjel on Medium]]></title>
        <description><![CDATA[Stories by Danjel on Medium]]></description>
        <link>https://medium.com/@danjel?source=rss-8c5490734006------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xNS_QXEuKtg23Oo8e_h-CA.jpeg</url>
            <title>Stories by Danjel on Medium</title>
            <link>https://medium.com/@danjel?source=rss-8c5490734006------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 20:25:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danjel/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[Only allow a Git commit if your Mocha tests are successful]]></title>
            <link>https://danjel.medium.com/only-allow-a-git-commit-if-your-mocha-tests-are-successful-6b6a78028520?source=rss-8c5490734006------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b6a78028520</guid>
            <dc:creator><![CDATA[Danjel]]></dc:creator>
            <pubDate>Sun, 18 Oct 2015 22:57:10 GMT</pubDate>
            <atom:updated>2020-10-23T08:30:18.715Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p><strong>⚠️ Warning:</strong> This post is from 2015 and doesn’t really reflect the state of the art anymore. Today (five years later!), I’d advise you to use <a href="https://github.com/typicode/husky">Husky</a>, which simplifies the setup of all kinds of Git hooks. Here is the post for historical reasons:</p><p>Test driven development is the way to go. It has to be. You should enforce it in your projects! But how will you do that? With git hooks, of course. Let me show you the way.</p><p>(This will, of course, only work, if you’re already using Git, nodejs and Mocha. But I’m sure you are, because you’re not an animal.)</p><h4>How to do it</h4><p>In your project, open the .git/hooks folder and create a file simply called pre-commit. Add this as its contents:</p><pre><strong>#!/bin/bash</strong><br><strong>export</strong> PATH=&quot;/usr/local/bin:$PATH&quot;<br>&quot;/Users/$USER/.npm-packages/bin/mocha&quot; &quot;tests&quot;</pre><p>Disclaimer: This looks a little fancy because I wanted it to work with my Git client, <a href="http://www.git-tower.com/">Tower</a>. Because of that, I had to set my PATH so Tower can find node, and give the full path to Mocha. If you only use the git command line, you may only need:</p><pre><strong>#!/bin/bash</strong><br>mocha tests</pre><h4>Expected behaviour after you set it up</h4><p>Whenever git commit is executed, it will run your <a href="https://mochajs.org/">Mocha</a> tests. If there are no errors, everything will continue like before. But if there are errors, it will show you the Mocha output and stop the commit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b6a78028520" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>