typescript - 通过索引文件导出的 Sinon 存根函数
问题描述
考虑以下打字稿文件:
- A.ts
export const funcA = ()=>{}
- B.ts
export const funcB = ()=>{}
- 索引.ts
export * from './A.ts'
export * from './B.ts'
现在在我的测试中,如果我直接导入内部文件,我可以模拟它的成员:
import * as A from './A.ts'
sinon.stub(A,'funcA');
但是,如果我导入索引,它不会让我模拟它的成员:
import * as myModule from `./index.ts`
sinon.stub(myModule,'funcA'); // does not work
有人可以解释吗?有不同的方法吗?
解决方案
推荐阅读
- spring-boot - 带有 docker 文件和任务定义的 Spring-boot 配置文件最佳实践
- javascript - 每当我滚动浏览该部分时,突出显示我的导航栏菜单项?仅使用 Javascript
- sql - 带有实体框架 CORE / MSSQL 服务器的 REST-Api:在运行时计算并返回附加字段/属性
- node.js - 使用 node.js 使用 tensorflow.js 对一批图像进行训练模型
- javascript - 在页面重新加载时关闭事件源 (SSE)
- c# - 如何将空值传递给 WebAPI 中的可空类型
- php - 如何删除数组值中的第一个字符?
- javascript - 我可以将 Vue.js 数据属性连同它的设置器一起分配给局部变量吗?
- python - 在组可以更改的不同数据帧上进行方差分析的代码
- r - 从R中的数据框中删除一行中的重复元素