Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test sequence of function calls by Sinon.js?

How can I test sequence of function calls by Sinon.js?

For example i have three (3) handlers in object, and want define sequence of handler calls. Is there any possibilities for this?

like image 991
Eugene Krevenets Avatar asked Mar 31 '13 15:03

Eugene Krevenets


People also ask

How do you stub a function with Sinon?

The sinon. stub() substitutes the real function and returns a stub object that you can configure using methods like callsFake() . Stubs also have a callCount property that tells you how many times the stub was called. For example, the below code stubs out axios.

Which of the following Sinon test function that records arguments Return value the value of this and exception thrown if any for all its calls?

A test spy is a function that records arguments, return value, the value of this and exception thrown (if any) for all its calls.

What is the purpose of wrapping test in Sinon test ()?

Wrapping a test with sinon. test() allows us to use Sinon's sandboxing feature, allowing us to create spies, stubs and mocks via this.

What is Sinon testing?

Sinon JS is a popular JavaScript library that lets you replace complicated parts of your code that are hard to test for “placeholders,” so you can keep your unit tests fast and deterministic, as they should be.


1 Answers

http://sinonjs.org/docs/

sinon.assert.callOrder(spy1, spy2, ...)

Passes if the provided spies where called in the specified order.

like image 72
Eugene Krevenets Avatar answered Sep 22 '22 05:09

Eugene Krevenets