Fluent interfaces are an elegant way of expressing functionality in Javascript. Unfortunately, when it comes to stubbing and instrumenting these method calls, one may find it next to impossible to do so – resulting in one or more of the following less-than-ideal outcomes:
- Using said library sans fluent interface.
- Selecting an alternative on the sole basis of having a non-fluent interface.
- Not testing that snippet of functionality altogether.
In this post, we shall mock-up a fluent library called SuperAgent for testing.