Whenever I start to feel anxiety about a big change I’m making, I start writing more unit tests. I’ll write down my fear and then write a test that attacks, and eventually relaxes, that fear. There are two actions that I’ve been frequently using with test writing: skipping all but one test or single tests.
Skip a Test
Oftentimes I will create tests with empty bodies so that I don’t forget to write them. To skip a test which is incomplete or known to fail, you can use xit
:
xit('does the thing I want', () => { });
Once the test is complete or ready to be applied, you can change xit
back to it
.
Run a Single Test
To run only a single test with the Mocha test framework, use it.only
:
it.only('does the thing I want', () => { });
it.only
is especially helpful if you have a large test suite and just want the result of a work-in-progress test quickly.
Let’s be honest: writing tests isn’t very fun. Like taking your cousin to the school dance or changing a diaper. But test writing is important enough to save yourself, and more importantly, your users, from disaster.
How I Stopped WordPress Comment Spam
I love almost every part of being a tech blogger: learning, preaching, bantering, researching. The one part about blogging that I absolutely loathe: dealing with SPAM comments. For the past two years, my blog has registered 8,000+ SPAM comments per day. PER DAY. Bloating my database…
MooTools Star Ratings with MooStarRating
I’ve said it over and over but I’ll say it again: JavaScript’s main role in web applications is to enhance otherwise boring, static functionality provided by the browser. One perfect example of this is the Javascript/AJAX-powered star rating systems that have become popular over the…
Build a Toggling Announcement Slider Using MooTools 1.2
A few of my customer have asked for me to create a subtle but dynamic (…I know…) way for them to advertise different specials on their website. Not something that would display on every page, but periodically or only the homepage. Using a trick…
Source link
Leave a Reply