there's no new logic here to unit test.
Mocking is a Code Smell
Eric Elliott
10.3K65

Hey Eric, I really enjoy your writing and I enjoy working with pure functions and pipes. Here’s an observation: I think pipes/compositions do have room for error and should therefore still be tested for the following reasons:

  • You can get the order of the composition wrong.
  • You can call a curried function with an incorrect argument.

Here’s a simplified example:

object = { id: 2 }
prop = propName => object => object[propName]
multiplyBy = n => x => x * n
add = n => x => x + n
getIdAdd1AndDoubleIt = pipe(
prop('ID'), // Should be 'id'
multiplyBy(2), // I should have added 1 first
add(5) // I've added the wrong amount
)
getIdAdd1AndDoubleIt(object)
// NaN

You can mitigate second point by partially applying the curried function, but I think this is not always done or desired in practice.

So I’d personally rather have at least some simple testing to make sure the expected output is still coming out of the pipe.

Hope that makes sense!