Test doubles with Sinon

A few weeks after going to production, our validator is a complete success but it also happens that potential new customers would like to have different sets of validation rules. Fortunately, our validator is configurable, but we somehow need to specify a different configuration for each customer.

The act of configuring a different set of rules for each customer is clearly another operation of the system and, hence, a different feature, so we are not really interested in testing it in the validator tests. We would like to isolate the tests about the validator feature and the configuration feature. To do so, we need to create an interface in a way that allows the validator to ask for the correct set of rules for the configuration. ...

Get Learning Behavior-driven Development with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.