【发布时间】:2021-11-07 08:07:41
【问题描述】:
我正在尝试在测试中执行以下代码:
import Airtable from "airtable";
const base: string = 'xxx'
const getClient = () => new Airtable({apiKey: 'xxx'});
export async function getAirtableData(): Promise<string[]> {
return []
}
我的测试:
test('Airtable to ElasticSearch', async () => {
expect(await getAirtableData()).toBe([])
});
但是当我运行测试(使用 Jest)时,出现以下错误:
TypeError: Cannot read property 'bind' of undefined
编辑:在不使用 Jest 的情况下使用 ts-node 手动运行代码就可以了。
Google 只返回与我没有使用的 React 相关的问题。可能是什么问题?
【问题讨论】:
-
原代码是不是一模一样,原代码中是否涉及到“this”?
-
这是原码,是的。报错就行了
import Airtable from "airtable";我用的是airtable版本^0.10.1
标签: typescript jestjs