All quizzes
Free quiz · 20 questions in the bank

Sinon quiz

Test your Sinon knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

What is `sinon.createStubInstance(SomeClass)` used for?

In this round
  1. What is `sinon.createStubInstance(SomeClass)` used for?
  2. Why does testing code that depends on `Date.now()` or `new Date()` often benefit from Sinon's fake timers rather than just calling the real Date API?
  3. What does `sinon.sandbox` (or the modern `sinon.createSandbox()`) help manage?
  4. What does `sinon.stub(object, 'methodName')` do?
  5. What is a Sinon "fake timer" (`sinon.useFakeTimers()`) used for?
  6. How can a Sinon stub be configured to simulate an asynchronous function that resolves with a specific value?
  7. What does `stub.calledWith(arg1, arg2)` check?
  8. What is the key difference between a Sinon spy and a Sinon stub?
  9. Why is it important to call `.restore()` on a Sinon stub/spy after a test that replaced a method on a shared object?
  10. Can a Sinon stub be configured to behave differently on successive calls, e.g. failing the first time and succeeding after?
  11. What is a Sinon "stub"?
  12. What is a Sinon "spy"?
Gaps to close?
Read the curated Sinon notes — core concepts, patterns, interview prep.
Sinon notes

More quizzes

.NETAccessibilityAgileAgile MethodologyAirflowAkka