Series

Lock-step Refactoring

Refactoring a Node.js fake data library one safe step at a time: turning a module into a class, injecting it, and stubbing it with Sinon to steady the tests.

3 posts, oldest first

Two rows of neon blocks climbing in step, joined in pairs, above a synthwave grid
  1. 3 min

    Lock-step Refactoring in Node.js (Part 1)

    I am the maintainer of an open source project called fakergem. It is basically a port of one of my favourite Ruby gems, faker. I enjoyed using faker so much that I wanted to have a similar experience when working with fake data in Node…

    #Javascript

  2. 2 min

    Lock-step Refactoring in Node.js (Part 2)

    The story thus far… So in part one we refactored the Ancient faker module into a class. We updated the tests and everything was still working as expected 😎. So what do we do next? Why did we even start refactoring again? As I mentioned…

    #Javascript

  3. 2 min

    Lock-step Refactoring in Node.js (Part 3)

    The story thus far… In part two we refactored the Faker object into a class. This allowed us to inject it into our Ancient faker module. So now how to we use this to our advantage? Stubbing using Sinon Standalone test spies, stubs and…

    #Javascript