我有一个组件,在安装时应每30秒调用一次方法。我无法为此编写单元测试。能否请您分享下面的单元测试示例
methods: { loadMethod () { getData().then(response => { this.myArr = response.data }); } }, mounted: function () { var self = this; this.loadMethod(); var loadMethod = function () { self.loadMethod(); self.interval1 = setTimeout(loadMethod, 30000); }; self.interval2 = setTimeout(loadMethod, 30000); }