小编Quo*_* Vo的帖子

如何在玩笑中模拟 const 方法?

我在打字稿中单元测试代码,使用开玩笑。请教我如何模拟getData以返回预期值。我的代码如下:

// File util.ts
export const getData = async () => {
    // Todo something
    return data;
}

// File execution.ts import { getData } from './util';
function execute()
{
    // todo something
    const data = await getData();
    // todo something 
}
Run Code Online (Sandbox Code Playgroud)

javascript typescript jestjs

7
推荐指数
2
解决办法
6313
查看次数

标签 统计

javascript ×1

jestjs ×1

typescript ×1