茉莉花需要sinon.js吗?

2022-01-11 00:00:00 unit-testing jasmine javascript sinon

我在网上看到过一些例子,其中人们将 jasmine 与 sinon.但是,茉莉花支持间谍(据我所知,这是诗浓所做的).那么问题来了,诗浓在使用 Jasmine 时还有用吗?如果诗浓有用,究竟是什么让它成为茉莉花的好补充?

I've seen examples on the web in which people use jasmine together with sinon. However, jasmine has support for spies (which as I understand is what Sinon does). So, the question is, is Sinon still useful when using Jasmine ? If Sinon is useful what exactly makes it a good addition to jasmine ?

干杯

推荐答案

不,你不需要诗乃和茉莉花一起工作.但是 Sinon spy/mock/stubs 在某些情况下更方便.在 Jasmine 中模拟 setTimeout 时也有一个小错误,它可以与 sinon 一起按预期工作.

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.

相关文章