I was just on vacation for four weeks and I spent the entire time writing code.
Quick JavaScript testing tip: How to structure your tests?
Something that’s not talked very often when it comes to writing unit tests is how should you structure your test code? I’m not talking about “well, just put your code into a file in test/SomeTest.js”, but rather, how should the test code itself within your test case be structured? While it may feel inconsequential – afterall, it’s just a test, …
JavaScript Testing Tool Showdown: Sinon.js vs testdouble.js
When unit testing real-world code, there are many situations that make tests hard to write. How do you check if a function was called? How do you test an Ajax call? Or code using setTimeout? That’s when you use test doubles — replacement code that makes hard to test things easy to test. For many years, Sinon.js has been the …
230 Curated Resources and Tools for Building Apps with React.js
This post will curate the best resources, tools, libraries, and articles that will help you learn to build production applications with React.js. This 6000 word post will take you from getting started with React, through UI design, routing, testing, deployment, and continuous integration. There are many sections and you should feel free to jump to the resources you need.
Simplify your JavaScript code with normalizer functions
Everyone loves a good if-else tower! What could be simpler than nesting a few conditionals? if(stuff) { if(more stuff) { haha(); } else { cool(); } }if(stuff) { if(more stuff) { haha(); } else { cool(); } } Ok – that isn’t the most amazing thing in the world. In a simple example like this, it isn’t too bad. But …
4 non-JavaScript library topics to learn to take your skills to the next level
Every new year there’s always a bunch of articles about “Learn this in year 200X!” But the problem is.. they’re always about libraries. Learn PrototypeJS. Learn jQuery. Learn Backbone. Learn AngularJS. Now it’s Learn React (or some React-derivative) This stuff comes and goes! Chances are, your job mostly dictates the libraries you’d use. Even if you do get to pick …
Best practices for JavaScript function parameters
From time to time, people ask things like “should I use objects to pass function arguments”. I’m sure you recognize the pattern, as it’s common with many libraries: $.post({ a: ‘lot’, of: ‘properties’, live: ‘in’, here: ‘yep’ })$.post({ a: ‘lot’, of: ‘properties’, live: ‘in’, here: ‘yep’ }) But I would say this is not actually such a good idea. Let’s …
5 step method to make test-driven development and unit testing easy
What’s the hardest thing in test-driven development or unit testing in general? Writing tests! The syntax or the tools aren’t the problem – you can learn those enough to get started in 15 minutes. The problem is how to take some vague idea in your head about what you want to do, and turn it into something that verifies some …
What is property based testing (and how to do it in JavaScript)?
Ever wonder… what if you didn’t have to write specific tests with hardcoded test data? Or have you ever written a function which can take many different values as input? How can you test something like that easily with different values? These are the kinds of important questions in life that keep me up at night! (ok maybe not) But …
Staircase code – how short functions are not always the best solution
Have you ever seen code which at first look seems good.. but then as you try to figure it out (maybe to fix a bug), it just feels… wrong? For some reason the code just feels really difficult to follow – for no obvious reason! In this post, I’m going to explain one such occurrence that I ran into in …