jasonharper.blog - Jason Harper's nerd rant | (Mako Software Solutions)

Description: (Mako Software Solutions)

Example domain paragraphs

One  side effect  of using decorators is that a decorator will run when running unit tests run against the [decorated] function. I wanted a way to signal that a decorator should be ignored (ie, should not apply itself to the underlying function) for a certain condition (where, the  condition in this case is if we’re in a unit testing context).

I’m sure we could have a debate about whether this is a good thing or not, but in this case, the decorator was doing cross-cutting work that wasn’t directly related to the  unit under test , so I wanted to test each in isolation.

My decorator was a stand-alone function [originally] and decorator syntax isn’t directly supported on stand-alone functions (only functions on object literals or methods of a class ). So initially I wrapped my decorator in a function which would precede the decorator function at runtime and achieve my goal. So here’s essentially  what that looked like: