DEV Community

Discussion on: The difference between mocks and stubs, explained with JS

Collapse
 
snird profile image
Snir David

Thank you for the comment (:
Actually everything I described here still stands in any context, frontend as well as backend testings with nodejs.

Everything you say is right as well, mocks allow you the fake a behaviour of certain object, and to test the behavior in place. This is why it is recommended to just use mock on one object per test unit - this way you make sure you are testing just one behaviour and not looking at some irrelevant internals.

Regarding the JS and Python beingh dynamic languages - I think this is another, super interesting and dense, discussion. About the correctness of languages without static types and how you should test them differently than statically typed languages (if you should do it differently, at all).