jestjs - 如何将 jest.spyOn 与 typescript 命名空间一起使用
问题描述
我想知道如何使用该函数模拟包含在 Typescript 命名空间中的jest.spyOn
函数。
例如,如果我有:
// fileA.ts
export namespace helpers {
export const sayHello = () => console.log('hello')
}
// fileB.ts
import {helpers} from './fileA'
helpers.sayHello()
// fileB.test.ts
import * as helpers from 'fileB.ts'
// I don't know what to put here
const myMock = jest.spyOn(helpers, 'helpers.sayHello')
我如何模拟helpers
命名空间中的函数?
解决方案
推荐阅读
- python - 从两个列表生成字典
- c# - 数据未从启动中的 ILogger 发送到 App Insights
- python-3.x - 编写一个程序,对字符串变量中从开始到第二个“C”符号的所有符号进行切片
- ssas - 限制 DAX 查询的持续时间
- automation - 如何更改 CloudFlare 帐户中的多个站点 dns?
- python-3.x - numpy 导入错误 ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
- amazon-web-services - 云监视日志中的自定义网关响应消息
- javascript - 如何在 React Native 中使用 React.forwardRef()
- html - 如何使用 CSS 和 HTML 从右向左移动表格
- jquery - 如何使用范围设置jquery掩码