typescript - 模拟 window.URL.createObjectURL 时的 typescript-eslint/unbound-method
问题描述
我正在尝试让我的单元测试正常工作。它目前失败:
TypeError: URL.createObjectURL is not a function
我最终偶然发现:
所以我现在提供以下模拟:
test('my test', async (): Promise<void> => {
window.URL.createObjectURL = (object: any): string => object.toString();
然而,这使得 eslint 报告现在:
Avoid referencing unbound methods which may cause unintentional scoping of `this`.
即使读了两遍:
感觉(object: any): string => object.toString()
这里是对的。我错过了什么/误解了什么?
解决方案
推荐阅读
- python - Heroku Django 部署条纹问题 - 没有名为“条纹”的模块
- ruby - 如何在 Apache 中使用一个域名为不同的 Web 应用程序提供服务?
- python - 如何将 Python 版本添加到 Python 启动器?
- android - Android:仅突出显示一个单元格 - TableLayout
- unit-testing - 我正在尝试编写 16 位 ALU(使用结构编码)
- python - Django ORM:按列表中的值过滤结果,限制每个值的答案?
- c# - 如何创建 Unity 2D 敌人 AI 变向动画?
- php - 使一列数据唯一并相加
- postgresql - 故障转移后的 Postgres 故障恢复
- excel-formula - TRANSPOSE() 函数错误地在单元格值之间添加分号