Discussion Javascript NodeJS

Sinonjs – Standalone test fakes, mocks, stubs for JavaScript

SinonJS provides stand alone test spies, stubs and mocks. This is the mechanism we’ll be using to create our spies, stubs and mocks.

Spies: Creates fake functions which we can use to track executions. This means we can tell/ find out whether the function has been executed/ how many times its been called etc. We can also use spies on existing functions and get the same capability, to track those functions executions. We’ll see this in action a bit later.

Stubs: Enables us to replace functions. This gives us more control. We can return whatever we want or have our functions work in a way that suites us to be able to test multiple scenarios.

Mocks: They are fake methods, that have pre-programmed behavior and pre-programmed expectations.

Sinonjs provides all these mechanisms, makes us write extensive unit tests.

Stan

Stan is an experienced full-stack developer and software engineer who is focused on web and game development. He is enthusiastic about new technologies. Stan is highly skilled in many programming languages and frameworks, and he always tries to deliver the best approach.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *