Plurrrr

a tumblelog
Thu 19 Nov 2020

How to unit-test a private (non-exported) function in JavaScript

When writing unit-tests for JavaScript modules, we often encounter a dilemma wherein the module has some private functions that have not been exported. Testing a function that has been exported is easy since it can be imported in the unit testing framework, and the functionality can be tested. But how to unit-test a private (non-exported) function?

Source: How to unit-test a private (non-exported) function in JavaScript, an article by Saransh Kataria.

Refactoring a Loop That Was Trying Too Hard

The bug was difficult to fix because the code was so complex. I wasn’t really able to fix it until I simplified the code. Once the code was simplified the bug was easy to fix. While doing this I found an anti-pattern that I now call “One loop trying too hard”.

Source: Refactoring a Loop That Was Trying Too Hard, an article by Tom Limoncelli.

Adam's Acanthoscurria geniculata

In the early evening I managed to remove the lid of the enclosure of Adam's Acanthoscurria geniculata without disturbing the spider. The juvenile female tarantula was resting on top of its burrow, so I took several photos. She's very skittish and most of the time when I remove the lid she hides from view immediately.

Acanthoscurria geniculata resting on top of her burrow
Acanthoscurria geniculata resting on top of her burrow.