我使用Sinon在單元測試我的組件(用TypeScript和vue-class-component編寫)時存根API調用。在將單元添加到單元測試之後,仍然調用原始方法(不返回存根值)。 it('should set the text to bar', async() => {
const stubbedApiResponse =() => {
return 'bar';
我有以下函數使用bind將上下文綁定到then鏈。當我嘗試和測試,它拋出 TypeError: redisClient.hgetallAsync(...).bind is not a function
myFunc() {
let self = this;
return redisClient.hgetallAsync('abcde')
.bind({ ap