Would JavaScript Test Scaffolding Be Useful?

mtfoley

Matthew Foley

Posted on May 20, 2020

Would JavaScript Test Scaffolding Be Useful?

I've been writing code for over a decade, but I was born yesterday when it comes to many of the concepts in modern software development - one of those being testing and test coverage in JS.

A few months ago I forked a JS project on GitHub that I wanted to build on. It didn't have any tests in the repo, and after listening to a few podcast episodes, I started learning how to write tests.

I used mocha and istanbul/nyc to run the tests. After lots of search engine use and some hours of head-to-keyboard, I got things working to my satisfaction - It's not a big project at all, but my code coverage is in the 80% neighborhood, which I'm happy with!

The experience made me wonder though, would it be useful to have a tool that scaffolds test files for your JS? I ask because

  1. I was born yesterday when it comes to this and
  2. because in my particular case it was useful because I was building off of a library that didn't have it.

My first takes on a tool for this is called keurig (inspired sort of by mocha), and it's meant to be installed globally in NPM and used as a CLI. Right now it's using babel to just scaffold a test JS for any class definition it finds, but the feedback I've gotten so far is that classes are a tiny subset of what people would actually build tests for. I'm trying to sample different JS authoring patterns and see what kinds of things I can scaffold for.

Meanwhile, would you find something like this useful?
I should probably point out - something like this might already exist, but I actually haven't gone looking for it.

💖 💪 🙅 🚩
mtfoley
Matthew Foley

Posted on May 20, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related