Testing Moment.js with Jasmine
Testing Moment.js with Jasmine
我正在为使用moment.js根据增量找到最接近的现有日期的方法设置测试。
交货。如果传入的日期是2015-01-01,增量为1个月,则返回2015-09-01。
我需要的是能够设置moment.js当前日期(不会改变),这将用于从规范中调用的方法,否则测试将在未来失败。这个方法是有效的,我已经手动测试过了。我只是不知道如何为测试设置默认值。我尝试使用mock,但是没有成功。
如果您愿意使用库,那么sinon有一个useFakeTimers
特性,可以让您在单元测试中模拟系统时钟。这就是你想要做的事情——模拟系统时钟并在测试后重置它。
http://sinonjs.org/docs/时钟
相关文章:
- Fighting with FRP
- issue with FB.Event.subscribe
- 使用jasmine模拟对服务器的调用
- geolocation-marker.js conflict with markerclusterer.js
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- WebComponentsJS with IE10
- 为什么jasmine期望不验证是否抛出了错误
- 模拟chrome.storage.local函数使用Jasmine
- 指令的模板必须只有一个根元素:With restrict E&替换true
- Jasmine Testing with Angular Promise 无法使用 TypeScript 解析
- JavaScript: toLocaleString() testing with jasmine
- 单元测试窗口.onerror with jasmine.
- Jasmine和Karma with Jasmine给出了不同的结果
- Testing Moment.js with Jasmine
- AngularJS控制器的Unittest with Jasmine and Karma "无法读取属性
- Testing jQuery Hover with Jasmine
- Running jasmine specs headlessly with phantomjs
- Spying on console.error() with Jasmine
- Testing JavaScript readline with Jasmine