Making JavaScript Tests Fast, Easy, & Friendly

August 11, 2014

A few weeks ago, I presented a talk on “Making JavaScript Tests Fast, Easy, & Friendly” at the CascasdiaJS 2014 conference in Portland, OR.

The talk looks beyond the traditional technical details of wiring up test frameworks and focuses on creating processes and environments that help developers actually write and run application tests.

Making the Tests Faster, Easier, Friendlier

The motivation for the talk comes from our work with developer teams of various sizes at Formidable Labs, where we have observed the challenges, successes, and failures of test development as a part of the overall development workflow.

Essentially, these experiences can be culled down to the following:

  • If tests aren’t easy to write, then developers won’t write them.
  • If tests aren’t fast to run, then developers won’t run them.
  • If the organizational culture isn’t test-friendly, then developers won’t write or run the tests (and they’ll probably be unhappy to boot).

The talk dives into some tips and tricks to address these three broad goals as follows:

  • Easy
    1. Set a Foundation: Build an infrastructure everyone can use.
    2. Lower Barriers to Entry: Help new developers get acclimated with code and mentorship.
    3. Write it Down: Document everything test-related and keep things up-to-date.
    4. Teach & Learn: Provide onboarding and small, introductory test assignments.
  • Fast
    1. Know What to Look For: Focus on the application behaviors most likely to be slowing down your tests (e.g., network and waits).
    2. Find the Slow Pokes: Use your test tools to identify what is slow during tests.
    3. Fake It: Programmatically “fake” the parts of your application that are slow during the tests.
    4. Offer Shortcuts: Provide developers with subsets of tests to run when the whole thing is too slow to regularly run.
  • Friendly
    1. Find Champions: Encourage and promote developers who are considered project-wide testing leads.
    2. Win the Higher-Ups Over: Learn to speak your managers’ language to get top-down support in your organization for developer time spent writing and running tests.

These are just some of the tips that we’ve found useful for making testing better in our client projects at Formidable Labs. But, there are surely other good techniques for building a strong culture of testing in other organizations. (And, we’d love to hear your experiences!)

Media

The full video of my talk is available from YouTube. As an aside, the CascadiaJS YouTube Channel has videos from the other (fantastic) talks at this year’s conference.

For those just looking for the slides, you can try SlideShare site, where the final PDF resides.

Related Posts

Iterables in JS

July 12, 2022
A perhaps less well-known addition of the ES2015 spec is the addition of the iteration protocols. These protocols allow us JS developers to make use of iterables — a very powerful language feature that you’re likely already using in your day-to-day development, but maybe haven’t given too much thought to!

The Case for Consistent Documentation

April 21, 2021
Words can't begin to express the anxiety I felt leaving my first job last spring. As I put in my notice, a question kept nagging me: how could I wrap up two years in two weeks?

Game of Types: A Song of GraphQL and TypeScript

May 23, 2019
Over the last few years, the popularity of both GraphQL and TypeScript has exploded in the web ecosystem—and for good reason: They help developers solve real problems encountered when building modern web applications. One of the primary benefits of both technologies is their strongly typed nature.