Does jasmine need sinon.js?

孤人 提交于 2019-12-03 09:40:58

No you dont need Sinon to work with Jasmine. But Sinon spy/mock/stubs are more convenient in some cases. There is also a minor bug in mocking setTimeout in Jasmine, which work as expected with sinon.

I use Sinon with Jasmine for it's fakeServer capabilities. Sinon allows me to easily mock AJAX HTTP requests without relying on the state of my server. Sinon also provides lower-level http mocking functionality for when you really need to fine-tune your mocked services.

You can use SinonJS as an extension to Jasmine. Sinon has a very nice API for a mock server which is quite handy if you want to test REST calls without having a real backend. There is also a nice documentation which shows the combination of SinonJS with Jasmine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!