How to Test Code that Executes Subprocesses

I was writing some stuff that programmatically executed terraform via Hashicorp's terraform-exec library this week. This works by interacting with a terraform executable that you provide (along with a working directory) to the NewTerraform constructor. Here's the trick: when testing this code it does not need to interact with the real executable. It can subprocess… Continue reading How to Test Code that Executes Subprocesses

Building Your Own (JavaScript) Test Doubles

A test double is an object or function that behaves like a real piece of code, but is, instead, solely for a test. It mimics the functionality of something, without being that something. There are plenty of frameworks to deal with test doubles in JavaScript (like sinon), but it's helpful to the various types of… Continue reading Building Your Own (JavaScript) Test Doubles