问题标签 [ts-mockito]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular - 如何使用 ts-mockito 模拟对象窗口以进行单元测试
我在 angular 内部有以下实现service
,即所谓的AService
.
定义environment
如下
我的想法是,无论何时startDoSth
调用,都window.location.href
必须调用一次。这个想法的实现
但是,我得到了错误
TypeError:无法读取未定义的属性“getAllMatchingActions”
我猜这个实例window
没有被模拟,然后测试使用真实实例,可能有不匹配的东西!?
因此,我有一个想法,使用ts-mockito
stub 对象window
,然后我可以验证行为甚至结果。不幸的是,我不知道该怎么做。有什么建议么?
typescript - 如何验证被调用了多少次间谍对象的方法
我想检查多少次被称为间谍对象的方法。我不想嘲笑它(我想测试它的功能)。下面的代码不起作用(预期“bar()”将被调用 1 次。但已被调用 0 次。)
node.js - runTransaction 中的模拟事务
我想在runTransaction函数中模拟代码。
示例代码:
我想模拟transaction
,检查它是否用正确的数据 etc.pp 调用。
我设法模拟firestore()
但不知道如何模拟transaction
参数。