<?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[Caffeine and Testing - Medium]]></title>
        <description><![CDATA[A journal about software testing and Javascript. - Medium]]></description>
        <link>https://medium.com/caffeine-and-testing?source=rss----6b2253b6aa9---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Caffeine and Testing - Medium</title>
            <link>https://medium.com/caffeine-and-testing?source=rss----6b2253b6aa9---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:30:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/caffeine-and-testing" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mocha v4 Nears Release]]></title>
            <link>https://medium.com/caffeine-and-testing/mocha-v4-nears-release-7db3dafe191a?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/7db3dafe191a</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Christopher Hiller]]></dc:creator>
            <pubDate>Fri, 29 Sep 2017 19:26:24 GMT</pubDate>
            <atom:updated>2017-10-01T05:13:51.746Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<p><a href="https://github.com/mochajs/mocha">Mocha</a> v4.0.0 is nearing release. With this new version also comes the obligatory <strong>breaking changes</strong>, and I’ll enumerate them below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZqZVDXq5zNLciYzE39f8w.png" /><figcaption>Photo by <a href="https://unsplash.com/@anete_lusina">Anete Lūsiņa</a> / <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Mocha Will No Longer Support Node.js Pre-v4.0.0</h3><p>There are several reasons for this:</p><ol><li>These versions of Node.js are no longer maintained and (some) have known security vulnerabilities <em>which will not receive official patches</em>. Users of these versions should upgrade Node.js. For example, v0.10.0 and v0.12.0 have been end-of-lifed since October and December 2016, respectively.</li><li>Mocha’s <em>own</em> dependencies have already dropped support for these platforms, and so Mocha cannot address to security vulnerabilities or critical bug fixes in reasonable manner nor timeframe.</li><li>Mocha’s development environment can no longer run out-of-the-box in a pre-v4.0.0 environment.</li></ol><p>The following unmaintained versions of Node.js <strong>will no longer be supported</strong> by Mocha:</p><ul><li>v0.10.0</li><li>v0.11.0</li><li>v0.12.0</li><li>iojs</li><li>v5.x</li></ul><blockquote>Node.js v5.x is likely to work as long as Node.js v4.x does, but will not be in Mocha’s <a href="https://travis-ci.org/mochajs/mocha">build matrix</a>.</blockquote><p>It’s important to note that Mocha v3.x <em>will still work</em> on these platforms, but users can no longer expect upgrades.</p><blockquote>For further reading, see <a href="https://medium.com/@eranhammer/on-being-operationally-incompetent-4ca4fbccbf98">this article by Eran Hammer</a> and also the <a href="https://github.com/nodejs/Release#readme">Node.js Release Schedule</a>.</blockquote><p>The above change <em>also</em> means:</p><h3>Mocha Will No Longer Support npm Older Than v2.15.11</h3><p>Reasoning:</p><ul><li>npm v2.15.11 is the version which shipped with Node.js v4.0.0.</li><li>Even older versions didn’t support scoped packages (@foo/bar), nor the caret (^) semver range specifier. This made it virtually impossible to include production dependencies which used <em>either</em>of these features.</li></ul><p>Users are encouraged to upgrade to the latest version of npm.</p><p>Users of <a href="https://bower.io/">Bower</a> are <em>also</em> encouraged to upgrade, because:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4-YgHdIme8dzu-dm." /><figcaption><em>Bower rides into the sunset.</em> Photo by <a href="https://unsplash.com/@alwig64?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit">Alex Wigan</a> / <a href="https://unsplash.com/?utm_source=ghost&amp;utm_medium=referral&amp;utm_campaign=api-credit">Unsplash</a></figcaption></figure><h3>Mocha Will No Longer Support Bower</h3><blockquote>This may or may not make it into v4.</blockquote><p>Bower is an excellent tool to install front-end dependencies. However, over the years, more robust solutions have evolved. Its time has passed.</p><p>Mocha v4 will remove its “browser bundle” (mocha.js) from version control. This means bower will not install Mocha v4 out-of-the-box. There may be a workaround by means of a &quot;<a href="https://www.npmjs.com/package/bower-npm-resolver">resolver</a>&quot;, but YMMV.</p><h3>A Warning To Those Bundling Mocha</h3><p>This change <em>may also</em> impact those users bundling Mocha themselves via browserify, webpack, etc. The browser field will now point to mocha.js, which is <em>already</em> bundled. You may no longer need to bundle yourself, <em>or</em> you may need to find a different way to do it. <em>If you cannot find a reasonable workaround, please open an issue on </em><a href="https://github.com/mochajs/mocha/new"><em>our tracker</em></a><em>.</em></p><p>Finally, my favorite:</p><h3>Mocha Will No Longer Support Non-ES5-Compliant Environments</h3><p>Mocha is likely the last major actively maintained testing framework to officially support these browsers.</p><p>While Mocha’s maintainers have proudly sustained the <em>poor, piteous developers</em> who have such business (or government!) requirements, the overhead of retaining compatibility has become an albatross.</p><p>Much like supporting older versions of Node.js, this has severely limited the project’s agility. Mocha should shed some weight after this, as it contains a plethora of handrolled shims.</p><p>The following browser environments <strong>will no longer be supported</strong> in Mocha v4:</p><ul><li>Internet Explorer 7</li><li>Internet Explorer 8</li><li>PhantomJS 1.x</li></ul><p>API and output changes follow.</p><h3>Other Breaking Changes</h3><p><strong>Read this</strong> to save yourself some time.</p><h4>Mocha Won’t Force Exit</h4><blockquote>This may or may not make it into v4.</blockquote><p>To avoid false positives and encourage better testing practices, Mocha will no longer <a href="https://github.com/mochajs/mocha/issues/2879">automatically kill itself</a> via process.exit() when it thinks it should be done running.</p><p>If the mocha process is still alive after your tests seem &quot;done&quot;, then your tests have scheduled something to happen (asynchronously) and <em>haven&#39;t cleaned up after themselves properly</em>. Did you leave a socket open?</p><p>Supply the--exit flag to use pre-v4 behavior.</p><p>If you’re having trouble figuring out where the hangup is, <a href="https://www.npmjs.com/package/why-is-node-running">this package</a>might help.</p><h4>Output</h4><p>There will be a few changes to reporters, which may negatively affect projects consuming Mocha’s output directly:</p><ul><li>The “unified diff” <a href="https://github.com/mochajs/mocha/issues/2295">will now contain separators</a>, as it has been difficult to read.</li><li>Upon error, the test contexts <a href="https://github.com/mochajs/mocha/pull/2814">will be indented</a> instead of smooshed into a single line.</li></ul><h3>Forward!</h3><p>By shedding support for older environments, Mocha becomes more nimble, and positions itself to leverage the present and future innovations of Node.js and JavaScript.</p><p><em>This article originally </em><a href="https://boneskull.com/mocha-v4-nears-release/"><em>appeared on boneskull.com</em></a><em>, September 29, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7db3dafe191a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/mocha-v4-nears-release-7db3dafe191a">Mocha v4 Nears Release</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript: Pure functions helped simplify unit testing for me.]]></title>
            <link>https://medium.com/caffeine-and-testing/javascript-pure-functions-helped-simplify-unit-testing-for-me-baf8baf08a7f?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/baf8baf08a7f</guid>
            <category><![CDATA[ecmascript-6]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Ken Aguilar]]></dc:creator>
            <pubDate>Tue, 28 Feb 2017 21:01:25 GMT</pubDate>
            <atom:updated>2017-03-12T07:15:57.238Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ap0MqBYVXj-rQheao9nyA.jpeg" /><figcaption><a href="https://unsplash.com/@tfaustin">https://unsplash.com/@tfaustin</a></figcaption></figure><p>I’m gonna start out by saying that I’m not an expert at functional programming. Functional programming is something that I have recently started learning. After learning just a few concepts of functional programming and applying it to my code my program already reads a lot better, and is a lot simpler with out any magic!</p><p>Before learning about pure functions I wondered how my state would change unexpectedly. When I run a program it produces an expected a result. However, the next time I run that program or I put in another input the result will totally be unexpected. Keeping track of the state with functions that mutate the state made it difficult to test, because of this I never tested my functions; and I just hoped for the best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*CoaVTi0BtFbzLbSWckc4Ww.jpeg" /></figure><p>Let’s say I have a person object, and I have to add stuff to the favoriteFood list.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2893ab6ef3bf2b5152c313728061721/href">https://medium.com/media/b2893ab6ef3bf2b5152c313728061721/href</a></iframe><p>This would be my solution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9f0688b0777a7e47ea375827e2353c6/href">https://medium.com/media/c9f0688b0777a7e47ea375827e2353c6/href</a></iframe><p>I call the function, put ‘ramen’ as an input and person object has now ramen in it as one of the favorite food. Great! It did what I wanted.</p><p>However, it is very hard to test this function once it’s mixed in with a bigger program. If there is an unexpected change I would have to do console.logs almost every line to check where the change is happening. It’s fun a couple of times hunting for that little bug but it becomes redundant and highly inefficient. It’s also a pain for other developers trying to help you out.</p><p>This is my attempt at testing that code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd71fd246c0b40f87c7688770cc1461d/href">https://medium.com/media/bd71fd246c0b40f87c7688770cc1461d/href</a></iframe><p>Yay! But... As you can see I’m testing the person object not the favoriteFood() function. What if I have a bunch of operations acting on the person object, how can I keep track of all the changes? How can I make a test? I would have to keep track of all the mutations or changes to assert a result.</p><p>A couple of the fundamental concept of pure functions are: <br> 1. A pure function must only operate on the input it is given and nothing else.<br> 2. That function must return the output of that operation.<br> 3. No side effect.</p><p>That’s it! It shouldn’t affect anything else, a pure function should not affect the person object.</p><p>With those concept, this is my amended function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b86ecb7f9b56d2ee544da8cb5e8e349/href">https://medium.com/media/0b86ecb7f9b56d2ee544da8cb5e8e349/href</a></iframe><p>This solution is heavily influenced by Dan Abramov’s redux. I am using a reducer function, it takes in the state(person object) and an action. An action is an object containing an instruction and the payload.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/782b812a1830521dfd36c4e35946e9dc/href">https://medium.com/media/782b812a1830521dfd36c4e35946e9dc/href</a></iframe><p>The test!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ca5decd1bdcc5ea9ec8b8c437d90a3/href">https://medium.com/media/06ca5decd1bdcc5ea9ec8b8c437d90a3/href</a></iframe><p>Now, I only have to assert the output of the function in my test. I don’t have to account for other effects of other functions, I only have to test for the output of a single function. If all my functions are pure I wouldn’t have to worry about the state changing under my feet.</p><p>However, in order for my program to do something it has to have changes but instead of several functions changing the state. I need a central point where all changes happen. In redux it is called the store. The store is where all the output of the reducer function goes, but that subject is for another article!</p><p>This is my first article ever, I hope this was coherent; and I hope it will help developers who are still confused about unit testing. For any constructive criticism don’t hesitate to contact me. This will tremendously help me improve.</p><blockquote>No state was harmed in the operation above…</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baf8baf08a7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/javascript-pure-functions-helped-simplify-unit-testing-for-me-baf8baf08a7f">Javascript: Pure functions helped simplify unit testing for me.</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My very personal Javascript Fatigue: the truth about JS testing]]></title>
            <link>https://medium.com/caffeine-and-testing/my-very-personal-javascript-fatigue-the-truth-about-js-testing-2ef0ab3f2198?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/2ef0ab3f2198</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Michele Nasti]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 21:57:03 GMT</pubDate>
            <atom:updated>2017-02-27T21:57:03.261Z</atom:updated>
            <content:encoded><![CDATA[<p>Trying to write this as a 2007 blog post: personal, not so politically correct. (I’m not involved in JS politics by the way)</p><p>Well, In 2007 I was already studying <strong>Javascript</strong>, <strong>HTML</strong> and <strong>CSS</strong>, and I vividly remember that I <strong>HATED</strong> the web world because different browsers were doing crazy stuff for the same instruction. These were the good ol’ <em>HTML 4</em> days.</p><p>I was pretty wrong. Browser apps are everywhere.</p><p>I have worked with a lot of javascript till now, I have also started a <a href="http://michelenasti.com/2016/02/javascript-meetup-a-salerno/">Javascript Meetup</a> here in my home town, Salerno. I have mentored and teached people about NodeJS. I have explained the story of the <em>single thread</em> and the differences between browsers and servers … and still, there was something that I was missing.</p><h3>Everybody talks, nobody really does it: TESTING</h3><p>It’s very easy to say that <strong>testing is important</strong>, it’s just three words nonetheless. I have heard this a thousand times, from a bazillion of people. However, when I have asked to talk to me honestly about javascript testing, the answer was more or less:</p><blockquote>nobody really does testing</blockquote><p><strong>WTF?</strong> I have heard this from people that I respect, and at many companies where I was interviewed. Why?!</p><blockquote>Our apps are not so big that you can’t test them manually</blockquote><p>Well, this can be an explanation, but not a great one.</p><blockquote>I can’t find any resources about testing in javascript</blockquote><p>Uhm … we are reaching the point …</p><blockquote><strong><em>Testing in javascript is f***ing difficult</em></strong></blockquote><p>Now that’s the truth, ol’ boy. Let’s dive into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*cGPyJNnScCSGNS2W." /></figure><h3>My personal testing jurney</h3><p>I decided to revamp a very old project, written in Java and Swing (yes, it was a standalone application, that’s how computers worked in 2010). In 2016, since browsers can do better things than before, I have decided to rewrite everything in javascript and to write the frontend in something that is more maintainable.</p><p>I decided to write my stuff in angular 1 (I know it very well and since I have no spare time this was the only option for me). As a build tool, i have decided to use <a href="http://gulpjs.com/">Gulp</a> + <a href="http://browserify.org/">Browserify</a>. For those who don’t know what Browserify is, well, it’s a JS library that lets you import other javascript modules exactly like NodeJs (so, you would use require(‘./TimerService’) to import it in your file). This has given me the ability to decouple angular from the actual JS code. Another advantage is that I can test it better, since it’s only Javascript.</p><p>What about Gulp? Gulp is a build tool that can do a lot of stuff for you. I use it to trigger actions every time I save a file, like running a syntax checker and convert my ES6 code to more archaic compatible ES5.</p><p>I also run my unit tests every time I hit Ctrl+S (save).</p><h3>How do you write unit tests in Javascript?</h3><p>It would be great to just say, “use this!” and we’re happy. In Javascript there are many libraries that are competing in the same space that there is no clear winner. I had to choose something that was well supported, well documented and used. I don’t know if they are the best for every scenario, but since my time is limited, I am using these because ̶t̶h̶e̶y̶ ̶w̶e̶r̶e̶ ̶t̶h̶e̶ ̶f̶i̶r̶s̶t̶ ̶r̶e̶s̶u̶l̶t̶ ̶o̶n̶ ̶G̶o̶o̶g̶l̶e̶ they worked at the first attempt.</p><p>One library? NO! In JS, at least for browser testing, you need:</p><ul><li>a test runner, like <a href="https://karma-runner.github.io/1.0/index.html">karma</a></li><li>a library to actually write the tests, like <a href="https://mochajs.org/">mocha</a></li><li>an assertion library, like <a href="http://chaijs.com/">chai</a></li></ul><p><strong>WTF, again?</strong> 3 libraries to do something that JUnit (for Java) does alone ?? This is an <strong>example of the over-populated, github-based, quality-variegated NPM package manager</strong>.</p><p>These 3 pieces of software still don’t have many years of maturity on their shoulders, and are not immune to bugs (which are promptly resolved, however). I have found one in mocha, for example, and I could not figure out until I upgraded.</p><p>Once you understand how to use these three libraries, then you have to actually write tests for your application: I don’t have words to describe how difficult is to test a function that uses multiple setTimeout() in the code (it’s an audio player, and deals with timing…). And now my next step in this journey is to mock stuff.</p><p>Another discovery I want to share with you (well, it’s not a discovery, since it’s on chai ‘s web page): you can check the test correctness in two ways, the assert way (like the one used in JUnit), or via a “behavioural” testing definition, something like “ expect(this).to.be.greaterThan(that) “. two syntaxes for the same thing.</p><h3>Moral of this ̶s̶t̶o̶r̶y̶ rant</h3><p>Do we really need testing in Javascript? I believe that yes, <strong>testing is fundamental as the application grows</strong>, and expecially if you want to do some refactoring that has some sense.</p><p><strong>Should it be this difficult to test stuff? No.</strong></p><p>At some point in the future, testing JS will be easy like every other language in the programming world. Modern languages born with testing capabilities built in, and Javascript is so old that testing was just not cool to think about it.</p><p>So, if you believe that your application will be refactored some time in the future, if you don’t want to become crazy, test it. <em>Test it now</em>. Run tests every Ctrl+S . This is the only way to be sure that things will not break up. Js is a dynamic language, it’s not statically typed, and IDEs do not do type checking for you. Help yourself with testing.</p><p>And finally, <strong>when testing will be cool again, you can say you were already doing it when stuff was being developed. </strong>You can talk like a good, ol’ Testing Granpa.</p><p><em>Originally published at </em><a href="http://michelenasti.com/2016/08/my-very-personal-javascript-fatigue/"><em>michelenasti.com</em></a><em> on August 30, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ef0ab3f2198" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/my-very-personal-javascript-fatigue-the-truth-about-js-testing-2ef0ab3f2198">My very personal Javascript Fatigue: the truth about JS testing</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing React & Redux Applications]]></title>
            <link>https://medium.com/caffeine-and-testing/testing-react-redux-applications-fee79ac0087f?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/fee79ac0087f</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Ryan C. Collins]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 21:56:53 GMT</pubDate>
            <atom:updated>2017-02-27T21:56:52.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*Q26gw-kNzOXUqZKRr04T-g.png" /></figure><p>Just like everything in the JavaScript world, there are 100s of different testing utilities to choose from to test React applications. I am hoping that this article can serve as a starting point for others who are looking to setup a testing stack in their projects.</p><h3>Background</h3><p>In the <a href="https://github.com/RyanCCollins/scalable-react-boilerplate">Scalable React Boilerplate</a> project, an open source micro-framework that I maintain, I have gone through numerous different testing setups, finally arriving at the one I am using primarily today. Initially, we started with a setup that used Karma, Mocha, Enzyme, Sinon and Expect. This setup was great, but it required complex setup to get right and it was also very slow, having to spin up a browser (or multiple browsers) each time it ran the test suite.</p><p><a href="https://grommet.github.io/">GrommetUX</a>, an open source React UX framework recently released a new testing setup that primarily uses Facebook’s <a href="https://facebook.github.io/jest/">Jest</a> testing framework. As a contributor to the GrommetUX project, I gained a great appreciation for how much Jest’s snapshotting feature simplified the testing for Grommet, which is a very large and complex UI component library.</p><p>You can read a bit about how the Grommet team made the decision to integrate Jest <a href="https://blog.grommet.io/post/2016/09/01/how-we-landed-on-jest-snapshot-testing-for-javascript">here</a>. The highlight of the article, is the comical analogy of the Jest Snapshot system, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*Yt1Uw62DtC4NoYyqGW0gIA.gif" /></figure><p>This may have been a joke, but realistically it sums up the Jest snapshotting feature better than words could.</p><h3>Integrating Jest</h3><p>In order to integrate Jest, I needed to make sure that I could also continue to utilize <a href="https://github.com/airbnb/enzyme">AirBnb’s Enzyme library</a>, so I created a <a href="https://github.com/RyanCCollins/scalable-react-boilerplate/tree/feat_install_jest">branch of the boilerplate</a> project to give it a go. What I found was that there is a simple utility called enzyme-to-json that connects Jest and Enzyme together.</p><p>After this discovery, I was sold on the idea of transitioning to Jest. I spent an hour or two wiping out the Karma configuration and integrating Jest. It was a very smooth transition and as a result, my component tests have been greatly simplified.</p><p>Let’s take a look at a simple test using Jest and Enzyme.</p><pre>import Header from &#39;../index&#39;;<br>import { shallow } from &#39;enzyme&#39;;<br>import { shallowToJson } from &#39;enzyme-to-json&#39;;<br>import React from &#39;react&#39;;</pre><pre>describe(&#39;&lt;Header /&gt;&#39;, () =&gt; {<br>  it(&#39;should render with default props&#39;, () =&gt; {<br>    const wrapper = shallow(<br>      &lt;Header<br>        content=&quot;Hello World&quot;<br>      /&gt;<br>    );<br>    expect(shallowToJson(wrapper)).toMatchSnapshot();<br>  });<br>});</pre><p>As you can see, we are shallow rendering our component. Using the shallowToJson plugin, we are able to create a representation of our shallow rendered component and write that to a snapshot file. In practice, this technique allows you to record a snapshot of your component and use it as a means to record the history of your component. Changes to the component will no longer match the snapshot, which will cause a failing test the next time you run your test suite.</p><p>On top of this, we can continue to run non-shapshot based tests doing component introspection with Enzyme, which allows you to make assertions about the structure of your components.</p><h3>Testing Redux</h3><p>In integrating Jest, the Redux based tests did not need to be changed at all. Testing Redux applications is actually very easy, as the method for testing Reducers and Action Creators is just as predictable as writing them in the first place. In fact, this is one of the main draws to Redux. It makes testing so darn simple.</p><h4>Action Creators</h4><p>Testing action creators is as easy as asserting that given a specific input, they will return a specific output. Since action creators are pure functions that take input and return an Action, it is very simple to reason about the assertions. You can see an example of an action creator test <a href="https://github.com/RyanCCollins/scalable-react-boilerplate/blob/master/app/src/containers/FeatureFirstContainer/tests/actions.test.js">here</a>, and below is a short example.</p><pre>import expect from &#39;expect&#39;;<br>import * as actions from &#39;../actions&#39;;<br>import {<br>  LOAD_DATA_INITIATION,<br>  // ... More constants here<br>} from &#39;../constants&#39;;</pre><pre>describe(&#39;FeatureFirstContainer actions&#39;, () =&gt; {<br>  it(&#39;should dispatch an action to initiate loading&#39;, () =&gt; {<br>    const expectedAction = {<br>      type: LOAD_DATA_INITIATION,<br>    };<br>    expect(<br>      actions.loadDataInitiation()<br>    ).toEqual(expectedAction);<br>  });<br>  // ... more tests here<br>});</pre><p>As you can see, we are asserting that the action creator returns the expected action. Also note that we are still using the Expect library here. Jest does include a built in assertion library, but it is also possible to use any other assertion library simply by importing it in your tests.</p><h4>Reducers</h4><p>Testing Reducers is just as easy as testing our action creators since Reducers are also pure functions. All we need to do is make assertions about the state before the reducer and then the state after the reducer. <a href="https://github.com/RyanCCollins/scalable-react-boilerplate/blob/master/app/src/containers/FeatureFirstContainer/tests/reducer.test.js">See here </a>for a full example test.</p><p>In the example above, we are setting the state to show that the UI is loading data, so our reducer test will look something like this:</p><pre>it(&#39;should initiate loading&#39;, () =&gt; {<br>  const stateAfter = {<br>    isLoading: true,<br>    data: {},<br>    error: {},<br>  };<br>  expect(<br>    reducer(initialState, {<br>      type: types.LOAD_DATA_INITIATION,<br>    })<br>  ).toEqual(stateAfter);<br>});</pre><h4>Connected Containers</h4><p>Testing connected containers introduces a bit of complexity because our state needs to be connected to the Redux Store. Redux makes this pretty simple, however, providing us with a mock store.</p><pre>import FeatureFirstContainer from &#39;../index&#39;;<br>import React from &#39;react&#39;;<br>import { shallow } from &#39;enzyme&#39;;<br>import { shallowToJson } from &#39;enzyme-to-json&#39;;<br>import configureMockStore from &#39;redux-mock-store&#39;;<br>import thunk from &#39;redux-thunk&#39;;<br>import { initialState as featureComponent } from &#39;../reducer&#39;;</pre><pre>const middlewares = [thunk];<br>const mockStore = configureMockStore(middlewares);</pre><pre>describe(&#39;&lt;FeatureFirstContainer /&gt;&#39;, () =&gt; {<br>  it(&#39;renders with default props&#39;, () =&gt; {<br>    const store = mockStore({ featureComponent });<br>    const wrapper = shallow(<br>      &lt;FeatureFirstContainer store={store} /&gt;<br>    );<br>    expect(shallowToJson(wrapper)).toMatchSnapshot();<br>  });<br>});</pre><p>As you can see above, we are able to mock our store fairly easily. We import our initial state and pass it into our mock store with the proper key, in this case featureComponent. Once the store is properly mocked, it’s just like testing any other component.</p><h3>More Resources</h3><p>This article is meant to be more of a starting place, rather than an in depth guide to testing React applications. Please feel free to take a look at the setup in the <a href="https://github.com/RyanCCollins/scalable-react-boilerplate">Scalable React Boilerplate project</a>, or any of my other <a href="https://github.com/RyanCCollins">open-source projects</a>.</p><p>Included below are some of the resources I used in setting up and testing my React projects.</p><ul><li><a href="http://airbnb.io/enzyme/docs/api/index.html">Enzyme API Reference</a></li><li>GrommetUX <a href="https://blog.grommet.io/post/2016/09/01/how-we-landed-on-jest-snapshot-testing-for-javascript">Blog Article</a> about Jest</li><li><a href="https://semaphoreci.com/community/tutorials/getting-started-with-tdd-in-react">Getting started with TDD with React</a></li><li><a href="http://redux.js.org/docs/recipes/WritingTests.html">Unit Testing Redux</a></li><li><a href="https://github.com/RyanCCollins/scalable-react-boilerplate">Scalable React Boilerplate</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fee79ac0087f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/testing-react-redux-applications-fee79ac0087f">Testing React &amp; Redux Applications</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit testing JavaScript code in the browser]]></title>
            <link>https://medium.com/caffeine-and-testing/unit-testing-javascript-code-in-the-browser-b9c97120f030?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/b9c97120f030</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jose Marmolejos]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 21:56:42 GMT</pubDate>
            <atom:updated>2017-02-27T21:56:42.324Z</atom:updated>
            <content:encoded><![CDATA[<p>When asked about testing front end code, I’d usually reply with something like “I haven’t found the right tool and approach yet”, but maybe that’s because I wasn’t really looking. After searching around for a while <a href="https://qunitjs.com/">I found QUnit</a> and really liked how easy it was to get a bit of <a href="http://jsbin.com/yeficohisi">sample code</a> going.</p><p>Setup is pretty trivial, you just need this bit of markup:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44e18c230569deb480085192c67e399f/href">https://medium.com/media/44e18c230569deb480085192c67e399f/href</a></iframe><p>That {path-to-your-install} part will depend on how you install QUnit, as you can download the file or install it using Bower or npm. I would recommend using either of the later two for local development.</p><p>npm:</p><pre>npm install --save-dev qunitjs</pre><p>bower:</p><pre>bower install --save-dev qunit</pre><p>If you open that html file in the browser you should be seeing something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*7GYnDYHyToitlonikuhfdg.jpeg" /></figure><p>Now let’s say you need a class that takes a string representing a fraction and returns the decimal value that results from the operation, then you would have a test like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/631be08a104e71f916d3f84750a25a6c/href">https://medium.com/media/631be08a104e71f916d3f84750a25a6c/href</a></iframe><p>You can just refresh the page to run the test and get this in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*UOxJ0L_PwZgvZ1DI7C5NjQ.jpeg" /></figure><p>For this test to pass, a naive implementation like this does the trick:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e551cbca188e7a03c8c30409c477083/href">https://medium.com/media/6e551cbca188e7a03c8c30409c477083/href</a></iframe><p>Refresh the tests page again, and now we get that beautiful tone of tdd green we like so much.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*Q_2-WTfShVNqCqzLebVLkQ.jpeg" /></figure><p>Go ahead and play a bit with what we’ve been building so far, here’s an idea for another test to add: what happens when bogus input is supplied to the function?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9c97120f030" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/unit-testing-javascript-code-in-the-browser-b9c97120f030">Unit testing JavaScript code in the browser</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript testing for the 21st century]]></title>
            <link>https://medium.com/caffeine-and-testing/javascript-testing-for-the-21st-century-fcef7482a1cd?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/fcef7482a1cd</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[yolpos]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 21:56:24 GMT</pubDate>
            <atom:updated>2017-03-16T19:16:00.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zoQJk9We_K-48ObdhuXXzQ.png" /></figure><p>Tests are absolutely a must. Without tests, it is not possible to evolve software.</p><p>Yet, tests are additional code to write and maintain.</p><p>And they break; which is great if they do to inform us that we were about to introduce a defect in our API; frustrating (to use a euphemism) otherwise.</p><p>Software testing is defined as the process of determining the correctness of software under the assumption of some specific hypotheses.</p><p>But that definition on its own does not tell an important truth</p><p>A truth so important that all other things should be derived from this one. And all other things won’t matter if this truth is does not hold.</p><p>It goes like this:</p><blockquote><strong>If a test fails it must tell you why.</strong></blockquote><p>If the above statement does not hold true , it does not matter how good all other parts are.</p><ul><li>It does not matter that the tests are fully integrated in a continuous build environment.</li><li>It does not matter that the whole suite of tests executes under a few minutes.</li><li>It does not matter about the test coverage being close to 100%.</li></ul><p>Please, don’t get me wrong. All parts are important; but the ability to report failure in the most accurate way beats all others.</p><p>So how do we get there ?</p><ul><li>Simplify<br>You must move towards a minimalistic approach. Ideally you should not rely on any additional library except the one you are testing.</li><li>Write sequential.<br>Some of the best practice to write programming code do not apply for testing code. Testing code should be flat and sequential, should avoid cyclomatic complexity (except for test-checks). It should also avoid function definition and any form of parametrization.</li><li>Make it a program<br>Let your test be a program. If it runs successfully then your tests have passed, if it fails looking at the program and the line/lines where it failed should tell you why.</li></ul><h3>yolpo</h3><p>It’s always been common to use code snippets in technical documentation to better illustrate the functionality of any given API.</p><p>We know that if a picture might be worth a thousand words, so is a code snippet to developers.</p><p>Consider the following snippets taken from http://lodash.com</p><pre>_.last([1,2,3]); // → 3<br>_.assign({ &#39;a&#39;<strong>:</strong> 1 }<strong>,</strong> { &#39;b&#39;<strong>:</strong> 2 }<strong>,</strong> { &#39;c&#39;<strong>:</strong> 3 })<strong>; <br>                            </strong>// → { &#39;a&#39;: 1, &#39;b&#39;: 2, &#39;c&#39;: 3 }<br>_.map([1<strong>,</strong> 2<strong>,</strong> 3]<strong>,</strong> function(n) { return n <strong>*</strong> 3<strong>;</strong> })<strong>; <br>                            </strong>// → [3, 6, 9]</pre><p>We can make a test of them</p><pre>x = _.last([1,2,3])<br>if (x !==3 ) throw &#39;&#39;;<br>x = _.assign({ &#39;a&#39;: 1 }, { &#39;b&#39;: 2 }, { &#39;c&#39;: 3 });<br>if (x == undefined) throw &#39;&#39;;<br>if (x.a != 1) throw &#39;&#39;;<br>if (x.b != 2) throw &#39;&#39;;<br>if (x.c != 3) throw &#39;&#39;;<br>x = _.map([1, 2, 3], function(n) { return n * 3; });<br>if (x == undefined) throw &#39;&#39;;<br>if (x.length !== 3) throw &#39;&#39;;<br>if (x[0] != 3) throw &#39;&#39;;<br>if (x[1] != 6) throw &#39;&#39;;<br>if (x[2] != 9) throw &#39;&#39;;</pre><p>Arguably, we have traded some of the beauty of using comments to express the expected results, but now we have made a regression test for it.</p><p>We still need one final thing: a bit of code to identify uniquely the library under test:</p><pre>load(&#39;<a href="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.min.js">https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.min.js</a>&#39;);</pre><p>The load function might require a bit of explanation. Yolpo introduces the global function load because javascript does not have a mechanism to load a script from a URL synchronously.</p><p>So now let’s take a look at the complete code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/417976a31732c590ee81c38ad9ff4e8d/href">https://medium.com/media/417976a31732c590ee81c38ad9ff4e8d/href</a></iframe><p>There are a few possible outcomes.</p><ul><li>It runs successfully.<br><em>Great news. Our regression test (no matter its coverage) has passed.</em></li><li>It fails at line 5.<br><em>We would then ask yourselves. Have I lost the internet connection ? Is cloudfare down ?</em></li><li>It fails at any line 7–19.<br><em>Fair enough, but now for every line we should be able to work out which function in lodash is broken and how.</em></li></ul><p>See the running example here:<br><a href="http://www.yolpo.com/embed.html?gist=933277296df75a382a16">http://www.yolpo.com/embed.html?gist=933277296df75a382a16</a></p><h3>Summary</h3><p>You do not need any framework/testing library to test. Your testing code should be simple, sequential javascript.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcef7482a1cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/javascript-testing-for-the-21st-century-fcef7482a1cd">Javascript testing for the 21st century</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On Unit Testing]]></title>
            <link>https://medium.com/caffeine-and-testing/on-unit-testing-1cc6798f81ee?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/1cc6798f81ee</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Kevin Ennis]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 17:08:29 GMT</pubDate>
            <atom:updated>2015-07-26T14:31:24.854Z</atom:updated>
            <content:encoded><![CDATA[<p>In the past few years, I’ve done kind of a 180° on unit tests.</p><p>There are a lot of really easy ways to rationalize <em>not</em> testing your code, and I’m probably guilty of saying each of them at one point or another.</p><ul><li>“It takes too much time”</li><li>“That’s what QA is for”</li><li>“A passing test suite doesn’t guarantee that you don’t have bugs”</li><li>“I tested it myself before I committed to master”</li><li>“[some feature I’m working on] isn’t really testable”</li></ul><p>For some engineers, I think the reluctance to embrace unit testing is basically just <a href="https://en.wikipedia.org/wiki/Fear,_uncertainty_and_doubt">FUD</a>. Like so many other things, testing seems scary if you haven’t done it before.</p><p>But it’s also really difficult to fully understand the benefits of testing unless you’ve worked on a project that <em>has good tests</em>. So it’s easy to see why — without fully understanding the upside — many developers regard unit testing as an unnecessary step.</p><h3>It takes too much time</h3><p>This argument is actually pretty rational if you don’t understand the long-term benefits of testing.</p><p>For a lot of the projects I work on, testing a new feature takes longer than actually implementing it. At first glance, that seems like a crazy way to invest my time.</p><p>But there’s an important piece of information missing here:</p><p><strong>Over the long-term, having good tests will save you a huge amount of time.</strong></p><p>The first time I ever refactored a piece of code with good test coverage, I actually felt a little bit <em>guilty</em>. It was almost too easy. Since I knew there was a safety net, I was free to try whatever I wanted. I didn’t have to remember all of the weird edge cases, because if I forgot them, the tests would fail.</p><p>Having good test coverage gives you a crazy amount of confidence going into a large refactor. It helps to ensure that you’re not introducing new bugs, which can ultimately save you a whole lot of time in the long run.</p><h3>That’s what QA is for</h3><p>Nope.</p><p>Nope nope nope nope nope.</p><p>QA does not exist so that we can be lazy and inattentive to detail. They’re a final line of defense against bugs. And they work at a much, much higher level of abstraction than engineers do.</p><p>Imagine an app with an off-by-one error. Maybe you’re rendering a list of users, but accidentally omitting the last one.</p><p>For QA to catch this, they need to know what the list <em>should</em> look like, and then notice that there’s an entry missing. Essentially, they need to be looking for this exact bug.</p><p>Then they need to reproduce it. They need to document it and file an issue. In all likelihood, they need to show their screen to some engineer who doesn’t believe that they could <em>possibly </em>have written code that breaks the app.</p><p>And all of that time is wasted, because a simple unit test would have caught the bug. Not just this time, but <em>every time. </em>Instantly and automatically.</p><h3>A passing test suite doesn’t guarantee that you don’t have bugs</h3><p>Wearing a seatbelt doesn’t guarantee you won’t be horribly injured in a car accident. Should we abandon any safety measure that isn’t 100% effective?</p><h3>I tested it myself before I committed to master</h3><p>Of all these terrible excuses, this is the one I’m probably most guilty of having believed in.</p><p><em>Of course it works. Why would I push code that doesn’t work?</em></p><p>This argument is compelling because there’s a tiny grain of truth to it.</p><p>If you’re attentive to detail and thoroughly test your new feature in the browser (or via HTTP or whatever the interface is), that <em>can be</em> functionally equivalent to unit testing.</p><p>But it’s hard to be sure that your new code didn’t break some other, unrelated part of the app. And more importantly, nobody else gets the benefit of the manual testing you did. That process happened once, and now it’s essentially lost.</p><p>Unit tests, on the other hand, are forever. They don’t just guard against bugs <em>right now</em>, they guard against bugs in the future.</p><h3>[some feature I’m working on] isn’t really testable</h3><p>For the past two years, every single application or library I’ve worked on has had 100% coverage.</p><p>If you’ve never used a code coverage tool (I like <a href="https://github.com/gotwarlost/istanbul">Istanbul</a> for JS), it’s essentially a process that instruments your code and then reports back on whether or not each line was executed while your test suite ran. If a line or expression was never run, it means you didn’t test it.</p><p>Anyway, in all of that time, I’ve only encountered one or two functions that couldn’t be written in a way that made them testable. Looking back, I’m not actually convinced that I couldn’t deal with those now by using dependency injection.</p><p>Sometimes you have to rethink the problem. Occasionally you even need to settle on an interface that’s less than ideal. But at the end of the day, it’s <em>extremely</em> unlikely that you’re working on a new feature that is literally <strong>impossible</strong> to test.</p><h3>Getting Started</h3><p>If you’ve been convinced that testing is important but don’t know where to start, I’d recommend looking at some open-source projects. Most high-profile OS repos have excellent coverage, and they can give you an idea of how to effectively test your code.</p><p>If you’re worried about getting buy-in from the rest of your team, here’s my recommendation:</p><p><strong>Start writing tests for your own contributions. Don’t even ask permission. Just do it*.</strong></p><p>I’d be willing to bet that the rest of your team will start to see the benefits before long.</p><p><em>*I did this at my last job, and it worked brilliantly. Within about a week, people were actually excited about it.</em></p><p>— -</p><p>Follow me on <a href="http://twitter.com/kevincennis">Twitter</a> or <a href="https://medium.com/@kevincennis/">Medium</a> for more posts. I’m trying to write once a day for the next 30 days.</p><p>And if you’re in the Boston area and want to come work on crazy, top-secret, fully unit-tested things with me at <a href="http://projectdecibel.com/">Project Decibel</a>, shoot me an <a href="/service/mailto:kennis84@gmail.com">email</a>. I’m hiring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cc6798f81ee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/on-unit-testing-1cc6798f81ee">On Unit Testing</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript testing using WallabyJs]]></title>
            <link>https://medium.com/caffeine-and-testing/javascript-testing-using-wallabyjs-5902e00ae1a1?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/5902e00ae1a1</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Samuele Resca]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 16:29:23 GMT</pubDate>
            <atom:updated>2017-02-27T16:29:22.639Z</atom:updated>
            <content:encoded><![CDATA[<h3>Javascript testing using Wallaby.js</h3><p><em>Originally written on </em><a href="http://samueleresca.net/"><em>samueleresca.net</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*_kX7njaQA2PpMfXe.png" /></figure><blockquote>Wallaby.js is <strong>insanely fast</strong>, because it <strong>only executes tests affected by your code changes</strong> and runs your tests <strong>in parallel</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*n1P8QM0u866nkts8.gif" /></figure><p><a href="http://wallabyjs.com/">Wallaby.js</a> is a test runner for JavaScript, it can be integrated in most common code editors/IDE and it provides a productivity boost whether you are doing TDD and BDD.</p><p>Wallaby.js is <strong>not free</strong>, but it is less expensive than some similar commercial solutions for other languages.</p><h4>The power of wallaby.js</h4><p>The <strong>power</strong> of Wallaby.js is the <strong>integration between tests and code editor:</strong> it reports code coverage and test results and error while you’re writing code. Wallaby.js supports a lot of technologies, you can find a lot of <strong>samples and templates</strong> on <a href="https://github.com/wallabyjs">github account</a>.</p><h4>Supported technologies</h4><p>Wallaby.js supports continuous testing in <a href="http://wallabyjs.com/#download">most common code</a> editor: <strong>Sublime text, Atom, Visual studio code, Visual Studio 2013/15 and WebStorm.</strong></p><p>It supports browser code testing (via <strong>PhantomJS or node.js</strong>) and node.js testing, it also supports many testing frameworks, for example: <strong>Jasmine, Mocha, QUnit</strong>. Finally, tests can also be written using <strong>TypeScript </strong>or<strong> CoffeeScript.</strong></p><h4>Installation and Configuration</h4><p>Wallaby.js can be installed as an extension of your code editor: for example, in VS Code you can simply install using extension manager:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*RE8dk48IlxAp7qAR.png" /></figure><p>Javascript testing using Wallaby.js needs a configuration file to work, recommended names are wallaby.js/wallaby.json or wallaby.conf.js. The following code shows some simple configuration options:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4126369712a89a08e941a29554d01fb/href">https://medium.com/media/c4126369712a89a08e941a29554d01fb/href</a></iframe><p><a href="http://wallabyjs.com/docs/config/overview.html">Here’s</a> the complete list of<strong> configuration options.</strong></p><h4>In my opinion..</h4><p>Keep in mind, <strong>Wallaby.js is not a file watcher</strong>: File watcher would run all of your JavaScript tests and it can be very time consuming. Wallaby uses dependency analysis and other tricks to only run tests affected by your code changes, no more no less, so even in large codebases with lots of tests the feedback is delivered very fast.</p><p>I have tried Wallaby.js on two IDE: <strong>Visual studio 2013</strong> and <strong>WebStorm 11</strong>. It has improved my <a href="http://samueleresca.net/2016/03/how-tdd-process-works/">TDD workflow</a>, I think it’s very useful because it can jump to failing test, error sources, show error details inline. It has also been easy to import my testing code written on Mocha and Chai.</p><p>Cheers :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5902e00ae1a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/javascript-testing-using-wallabyjs-5902e00ae1a1">Javascript testing using WallabyJs</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to test your Meteor.js web app using Chimp, Cucumber and Jasmine]]></title>
            <link>https://medium.com/caffeine-and-testing/how-to-test-your-meteor-js-web-app-using-chimp-cucumber-and-jasmine-4c2ba438c714?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/4c2ba438c714</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[meteor]]></category>
            <dc:creator><![CDATA[Adrien Joly]]></dc:creator>
            <pubDate>Mon, 27 Feb 2017 16:15:18 GMT</pubDate>
            <atom:updated>2017-02-27T16:15:18.329Z</atom:updated>
            <content:encoded><![CDATA[<p>I feel that automated tests are like teenage sex: developers talk a lot about it, but only few of them actually do it. (at least from the developers I talk with)</p><p>Yesterday, while I was integrating a complex login/signup flow on a <a href="https://www.meteor.com/">Meteor.js</a> web app for a client, I felt that this complexity could lead to future bugs. So I decided to write a test to make sure that it won’t fall apart on any future commit.</p><blockquote><strong>EDIT</strong>: At the time, I was using <strong>Chimp v0.24.1</strong>, running on <strong>Node v0.12.9</strong>.<br>Be careful, Chimp is evolving a lot, so this tutorial may already be deprecated.</blockquote><p>My problems were:</p><ul><li>I have very little experience with automated testing,</li><li>I had never written tests for a Meteor.js app,</li><li>and I was confused about the current best practices (if any) with that technology: <a href="http://xolv.io/blog-posts/2015/11/6/the-seven-testing-modes-of-meteor"><em>What tool should I use</em></a><em>?</em></li></ul><h4>Why did I struggle?</h4><p>Apparently MDG had <a href="http://info.meteor.com/blog/meteor-testing-framework-velocity">decided to use Velocity as their standard test driver</a>, but I could not see any reference to testing (besides tinytest for testing packages) in <a href="http://docs.meteor.com/#/full/">Meteor.js’ official documentation</a> and <a href="http://guide.meteor.com/">guide</a>.</p><p>I also read that <a href="https://forums.meteor.com/t/the-state-of-velocity-and-testing-in-meteor/15084/9">Chimp was the direction MDG was currently heading towards</a>. But I spent some time understanding how to setup my tests from scratch, because I had to discover several tools and langages at once:</p><ul><li><a href="https://github.com/xolvio/chimp">Chimp</a> (the test runner),</li><li><a href="https://cucumber.io/">Cucumber</a> (the langage for writing test scenarios),</li><li>and <a href="http://jasmine.github.io/2.3/introduction.html#section-Expectations">Jasmine</a> (the the langage for expressing test validation criteria).</li></ul><p>Moreover, these tools are generic, and Meteor.js brings additional objects and methods that can (or must) be used from Chimp and Cucumber.</p><h4>The setup process</h4><p>As explained on <a href="https://chimp.readme.io/docs/tutorial">their documentation</a>, I installed Chimp globally using `npm install -g chimp` so that I could run the `chimp` command from anywhere. On the first run, Chimp installed webdriver (or scelenium, I don’t remember).</p><p>But, the first run concluded with a weird error: `Directory features does not exist. Not running`, and I had not found any mention of that directory (or error) in Chimp’s documentation.</p><p>I had to find in <a href="https://chimp.readme.io/docs/tutorial">this tutorial</a> that tests had to be described in a `features` directory, using the <a href="https://cucumber.io/docs/reference#gherkin">Gherkin langage</a>. So I added a `./tests/features/test.feature` file in my Meteor.js project, to see what would happen:</p><pre>@watch<br>Feature: Search the Web<br><br>  As a human<br>  I want to search the web<br>  So I can find information<br><br>  Scenario: Search for Xolv.io<br>    Given I have visited Google<br>    When I search for &quot;Xolv.io&quot;<br>    Then I see &quot;Xolv.io&quot;</pre><p>As Chimp was running in `watch` mode, it provided me with some code in the console, to help me implement the corresponding tests:</p><pre>You can implement step definitions for undefined steps with these snippets:<br><br>this.Given(/^I have visited Google$/, function () {<br>  // Write the automation code here<br>  pending();<br>});<br><br>this.When(/^I search for &quot;([^&quot;]*)&quot;$/, function () {<br>  // Write the automation code here<br>  pending();<br>});<br><br>this.Then(/^I see &quot;([^&quot;]*)&quot;$/, function () {<br>  // Write the automation code here<br>  pending();<br>});</pre><p>So, by following the tutorial, and reading <a href="https://github.com/cucumber/cucumber-js">Cucumber-js’ docs</a>, I wrote the following `./tests/features/support/defs.js` file:</p><pre>module.exports = function() {</pre><pre>  // Hooks</pre><pre>  // this function is run before testing each scenario.<br>  // it makes sure that we&#39;re using a test (i.e. empty) database.<br>  this.Before(function(scenario) {<br>    console.log(&#39;meteor running on:&#39;,<br>      server._original.host + ‘:’ + server._original.port);<br>    console.log(‘about to test:’, scenario.getName());<br>    var result = server.execute(function() {<br>      console.log(‘counting...’); // displays in Meteor&#39;s console<br>      return Meteor.users.find().fetch().length;<br>    });<br>    expect(result).toEqual(0);<br>  });</pre><pre>  // this function is run after testing each scenario  <br>  this.After(function(scenario) {<br>    // TODO: clean DB, to prevent side-effects between tests<br>  });</pre><pre>  // Tests</pre><pre>  this.Given(/^I have visited Google$/, function () {<br>    browser.url(https://medium.com/&#39;http://google.com&#39;); // ...or localhost:3000 ^^<br>    // browser = WebdriverIO instance<br>  });<br><br>  this.When(/^I search for &quot;([^&quot;]*)&quot;$/, function (searchTerm) {<br>    browser.setValue(&#39;input[name=&quot;q&quot;]&#39;, searchTerm);<br>    browser.keys([&#39;Enter&#39;]);<br>  });<br><br>  this.Then(/^I see &quot;([^&quot;]*)&quot;$/, function (link) {<br>    browser.waitForExist(&#39;a=&#39; + link);<br>  });</pre><pre>  // I also added this test, based on another example:<br>  this.Then(/^They see the title &quot;([^&quot;]*)&quot;$/, function(title) {<br>    browser.saveScreenshot(&quot;screenshot.png&quot;);<br>    expect(browser.getTitle()).toEqual(title); // Jasmine Expect<br>  });  <br>}</pre><p>When both files are correct, and Chimp is running in watch mode from the ./tests directory, it’s working awesomely!</p><ul><li>Chimp opens a Chrome browser, and we can see tests running in that window, like if a real human user was doing it!</li><li>Test results display in Chimp’s console.</li></ul><p>But my `Before` hook prevents the tests from actually running, because the database is not empty. Indeed, as advised by <a href="https://chimp.readme.io/docs/getting-started-with-meteor-cucumber">Chimp’s Meteor tutorial</a>, I had launched Chimp that way:</p><pre>chimp --ddp=<a href="http://localhost:3000/">http://localhost:3000</a> --watch</pre><p>…which connects to my development Meteor.js instance, and thus, to my development database (containing data: users, etc…).</p><p>I found on a forum that it was ok to run two Meteor instances:</p><ul><li>one for development, by just running the `meteor` command;</li><li>and one for testing, by specifying different HTTP and DB ports.</li></ul><p>So I ended up writing the following `./tests.sh` script that I use today:</p><pre>#!/bin/bash</pre><pre># Startup Chimp testing instance<br>MONGO_PORT=3001<br>METEOR_PORT=3100</pre><pre>echo After METEOR IS READY, run: chimp --path=tests \<br>     --ddp=<a href="http://localhost:$METEOR_PORT">http://localhost:$METEOR_PORT</a> --watch</pre><pre>bash -c &quot;MONGO_URL=mongodb://localhost:$MONGO_PORT/chimp_db \<br>     meteor --port $METEOR_PORT $@&quot;</pre><p>When I’m working on my project:</p><ul><li>I run `meteor` to start the development instance, as usual;</li><li>then I run `./tests.sh` in another console, to start the testing instance.</li><li>When, the testing instance is running, I copy-paste the chimp command printed by my script, to yet another console.</li></ul><p>That way, I’m able to develop as usual from localhost:3000, using my development database; and to run tests in the background, on a dedicated (clean) database.</p><h4>In a nutshell (tl;dr)</h4><p>If you want to add end-to-end tests using Chimp+Cucumber+Jasmine to your Meteor.js project:</p><ul><li>Install Chimp;</li><li>Copy-paste the code blocks provided above, into the corresponding files;</li><li>Run ./tests.sh to start your testing Meteor instance, then the printed Chimp command to actually run the tests.</li><li>Add feature descriptions using Cucumber’s <a href="https://cucumber.io/docs/reference#gherkin">Gherkin langage</a>.</li><li>Add test definitions using <a href="https://github.com/cucumber/cucumber-js">Cucumber-js’ doc</a>, the <a href="http://webdriver.io/api.html">browser object API</a>, Meteor’s <a href="https://chimp.readme.io/docs/getting-started-with-meteor-cucumber">server and client objects</a>, and <a href="http://jasmine.github.io/2.3/introduction.html#section-Expectations">Jasmine’s expectations</a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c2ba438c714" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/how-to-test-your-meteor-js-web-app-using-chimp-cucumber-and-jasmine-4c2ba438c714">How to test your Meteor.js web app using Chimp, Cucumber and Jasmine</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</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 mocha]]></title>
            <link>https://medium.com/caffeine-and-testing/getting-started-with-mocha-bfa20d403186?source=rss----6b2253b6aa9---4</link>
            <guid isPermaLink="false">https://medium.com/p/bfa20d403186</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Jhey Tompkins]]></dc:creator>
            <pubDate>Thu, 27 Oct 2016 13:36:36 GMT</pubDate>
            <atom:updated>2016-10-27T13:36:36.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/desat/multiply/yellow/60/overlay/yellow/1*cNNUCYcRProOt3xU8O-Tbg.jpeg" /></figure><h4>getting set up and using with Travis CI</h4><blockquote>So you’ve written some code but what about your tests?</blockquote><p>Testing is a strange topic. I think maybe some people have the conception that testing is taxing to set up or not worth doing on their projects. But, testing on front end projects is not hard to set up with some great options out there. Also, testing can be a sign that a project has had more care and effort put into it. That might sound a little off but in the open source world, I think you instantly take a project a little more seriously if you see evidence of well tested code and some notification of a build passing when taking a look at a project.</p><p>Two of my favorite options for getting a project tested are using mocha and Travis CI.</p><h4>For those in camp TL;DR who just want some code to play with</h4><p>If you just want some code and tests to hack around with you can visit a demo repo at <a href="https://github.com/jh3y/testPlayground">github.com/jh3y/testPlayground</a>. This article references the repo.</p><h3>Mocha</h3><p><a href="http://visionmedia.github.io/mocha/">Mocha</a> is a great simple testing framework that runs on node.js and within the browser. It’s real easy to get set up and is real flexible in the way you use it.</p><h4>note</h4><p><a href="http://visionmedia.github.io/mocha/">Mocha</a> is concerned more so with functional testing of your code and not with navigation and interaction of your project/app UI. For that style of testing I’d recommend trying out something like <a href="http://casperjs.org/">CasperJS</a>.</p><h4>setting up</h4><p>There are quite a few steps here but all will be clear when we start writing out our simple tests.</p><p>Assuming you’re using node in your project in some fashion you will already have a package.json file in your project so go ahead and install mocha with</p><pre>npm install —-save-dev mocha</pre><p>This will add mocha as a devDependency to your project.</p><p>You will also want to add the following into your package.json.</p><pre>“scripts”: {<br>  &quot;test&quot;: &quot;make test&quot;<br>}</pre><p>This will come in useful when hooking into Travis CI later on.</p><p>You will want to create a <strong>Makefile</strong> by adding the file ‘Makefile’ to your project containing the following.</p><pre><strong>test:<br>       </strong>@./node_modules/.bin/mocha -u tdd --reporter spec</pre><pre><strong>.PHONY:</strong> test</pre><p>This enables us to run our tests from within the root of our project directory by simply using the command</p><pre>make test</pre><p>You could alternatively globally install mocha with</p><pre>npm install -g mocha</pre><p>and run the same command as with our makefile</p><pre>mocha -u tdd -—reporter spec</pre><p>This option is fine but it will make your project less consumable by others straight out of the box. Also you’re going to need that makefile for Travis.</p><p>As a note, mocha will by default look for tests within a ‘<strong>test’ </strong>directory if you wondered why no path was being passed to the command.</p><p>Lastly, and optionally, if you want to use <strong>mocha-phantomjs</strong> locally which is going to be used via Travis CI later install that too with</p><pre>npm install phantomjs -g<br>npm install -g mocha-phantomjs</pre><h4>options</h4><p>You might have noticed that I was passing options in with my mocha command in the setting up section. <strong>-u </strong>sets the testing interface. In these tests I am using test driven development. The <strong>--reporter </strong>option will set the style of reporter you like. This is just personal preference and I like the spec reporter myself (nyan is also quite amusing). You can check out more options at the site for <a href="http://visionmedia.github.io/mocha/">Mocha</a>.</p><h3>enough of that, let’s write some tests!</h3><p>So we’ve got all the set up out of the way. Let’s write some simple tests.</p><p>We are going to work with a simple library that exposes a <strong>plus</strong> function that will add two numbers.</p><p>Here is the node version.</p><pre>(function(){<br> exports = module.exports = plus = function (one, two) {<br>   return one + two;<br> };<br>}).call(this);</pre><p>Here is the browser version.</p><pre>(function(){<br> var plus = window.plus = function (one, two) {<br>   return one + two;<br> };<br>})();</pre><h4>testing out our node compatible version</h4><p>We are going to write out a simple test for our node based version. This is <strong>test.js </strong>located within the <strong>test</strong> directory (We are using node’s regular <strong>assert </strong>but you can use other assertion libraries with mocha such as <strong>should.js </strong>and <strong>chai.</strong>).</p><pre>(function() {<br>   var assert = require(“assert”),<br>     plus = require(“../lib/plus”);<br>   suite(“plus”, function() {<br>     test(“2 plus 3 should equals 5&quot;, function() {<br>       return assert.equal(5, plus(2, 3));<br>     });<br>   });<br>}).call(this);</pre><p>You can see in our test file that we pull in the <strong>plus</strong> lib file with require and then we have one test in place that will check that “2 plus 3 should equals 5&quot; and sure enough when we run</p><pre>make test</pre><p>In the root of the project we are greeted with output telling us our test has passed!</p><p>If you’ve made it this far, well done! You have now set up a test using mocha and now you can go further and add more tests to make <strong>plus</strong> a more practical library.</p><p>For example we could add the following test that implies that <strong>plus </strong>should throw an error if either parameter is not a number,</p><pre>test(“should throw error if NaN parameter”, function() {<br>   return assert.throws((function(){<br>     return plus(2, “string”);<br>   }), Error);<br>});</pre><p>Mocha will now return that a test is failing because we haven’t written the logic into our library to check parameter type.</p><h4>testing our browser based version</h4><p>Testing in the browser takes a little more set up but is still not hard to do. We need to set up a HTML page that will contain the browser based version of mocha, our <strong>plus </strong>lib file, and our browser tests (I grab mocha and chai using bower).</p><pre>&lt;html lang=”en”&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;tests : plus&lt;/title&gt;<br>    &lt;link rel=”stylesheet” href=”../vendor/mocha/mocha.css”&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;div id=”mocha”&gt;&lt;/div&gt;<br>    &lt;script src=”../vendor/mocha/mocha.js”&gt;&lt;/script&gt;<br>    &lt;script src=”../vendor/chai/chai.js”&gt;&lt;/script&gt;<br>    &lt;script&gt;<br>      mocha.setup(‘bdd’);<br>      expect = chai.expect;<br>    &lt;/script&gt;<br>    &lt;script src=”../js/plus.js”&gt;&lt;/script&gt;<br>    &lt;script src=”../js/test/test.js”&gt;&lt;/script&gt;<br>    &lt;script&gt;<br>      if (window.mochaPhantomJS) {<br>        mochaPhantomJS.run();<br>      } else {<br>        mocha.run();<br>      }<br>     &lt;/script&gt;<br>   &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Once this page is set up, I like to have it hosted on a static server along with whatever else I am working on. But, this isn’t necessary. As we can use <strong>phantomJS </strong>and in particular <strong>mocha-phantomjs</strong>.</p><p>If you installed these two earlier, you’re all set, if not</p><pre>npm install phantomjs -g<br>npm install -g mocha-phantomjs</pre><p>Now, to run our test page with <strong>mocha-phantomjs (</strong>You simply pass the path to your test page).</p><pre>mocha-phantomjs out/test/index.html</pre><p>The tests being ran in here can be the same tests (adjusted to use whichever assertion library you choose). But, with it being browser based, you’ve now got access to the DOM etc. A test to take advantage of this and one I like to throw in is checking that a function or library is available, especially if you safety wrap your javascript.</p><pre>describe(“plus”, function() {<br>  describe(“plus initialization”, function() {<br>    it(“should be available as a function”, function() {<br>      expect(typeof window.plus).to.equal(“function”);<br>    });<br>  });<br>});</pre><p>Running <strong>mocha-phantomjs</strong>, our test will pass stating that <strong>plus</strong> is indeed an available function in our page.</p><p>Once again you could extend this to check other things with our lib such as parameter type or even something like decimal points etc.</p><h3>Travis CI</h3><p>There has been quite a lot to digest as far but you’re nearly there.</p><p>Our last piece is Travis CI, a hosted continuous integration service for projects hosted on github. If you’re project isn’t to be hosted on github, you can certainly skip this.</p><p>Travis is real helpful and will run your tests automatically for you upon commits being made to your repos. It will then notify you of build status.</p><h4>getting setup</h4><p>You will first need a <strong>.travis.yml </strong>yaml file in your repo. If you are working with just a node based project, your yaml can get away with being very small.</p><pre>language: node_js<br>node_js:<br>  - &quot;0.10&quot;</pre><p>By default, when your project is being built and the language is set to <strong>node_js</strong>, Travis will actually look to run the test script defined within our <strong>package.json</strong> file. In our case, this means it will run</p><pre>make test</pre><p>Things are a tiny bit more complex with our browser based testing dependent on what code you have in your repo. You may not want to be adding output files to your repo such as output html and test files. Fear not. In the case of our <strong>plus</strong> project, our yaml file can be more like this</p><pre>language: node_js<br>node_js:<br> — “0.10&quot;<br>install:<br> — npm install phantomjs -g<br> — npm install -g mocha-phantomjs<br> — npm install -g gulp<br> — npm install -g bower<br> — npm install<br> — bower install<br>before_script:<br> — phantomjs —version<br> — mocha-phantomjs —version<br> — gulp &amp;<br> — sleep 5 # give gulp background task some time to execute.<br>script:<br> — mocha-phantomjs out/test/index.html<br> — make test</pre><p>It should be pretty self explanatory. But, for this particular project, I’ve used gulp, bower, phantomjs and mocha-phantomjs. The <strong>install</strong> section grabs all the project dependencies. The <strong>before_script</strong> section is defining what Travis needs to do just before it can run our tests/scripts. Lastly, <strong>scripts</strong> defines how to run our tests.</p><p>Once we have our .travis.yml file sorted out we need to actually set up our project in Travis. Get over to <a href="https://travis-ci.org/">https://travis-ci.org/</a> and sign in with your github account. Once signed in you can then pick which projects to turn off and on for CI. Switch your project on and upon your next commit, assuming .travis.yml is present within the root of your directory, tests will be ran automatically.</p><p>One last nice touch is that you can add a build status image to your project README or wherever by grabbing the URL of the build status image on your projects individual dashboard page.</p><blockquote>And, that’s it!</blockquote><p>You hopefully now have a slightly better understanding of how to get set up with Mocha and TravisCI for your github projects.</p><p>Be sure to check out the project repo I set up for this at <a href="https://github.com/jh3y/testPlayground">https://github.com/jh3y/testPlayground</a> if you’d like to hack about with some tests or get a better idea of how it’s set up.</p><p>Of course, any suggestions or questions, be sure to leave a note or tweet me!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfa20d403186" width="1" height="1" alt=""><hr><p><a href="https://medium.com/caffeine-and-testing/getting-started-with-mocha-bfa20d403186">Getting started with mocha</a> was originally published in <a href="https://medium.com/caffeine-and-testing">Caffeine and Testing</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>