Javascript 节点配置在typescript jest上下文中为“未定义”?
我有一个typescript模块,可以在开发和生产中使用。它使用我试图将其导入jest来编写测试,并抛出一个错误,表明配置对象未定义Javascript 节点配置在typescript jest上下文中为“未定义”?,javascript,node.js,typescript,jestjs,Javascript,Node.js,Typescript,Jestjs,我有一个typescript模块,可以在开发和生产中使用。它使用我试图将其导入jest来编写测试,并抛出一个错误,表明配置对象未定义 TypeError: Cannot read property 'get' of undefined at Object.<anonymous> (src/email/email.service.ts:1877:43) 我希望将config定义为config模块的默认导出 环境: node-config version: config@3.2.4 n
TypeError: Cannot read property 'get' of undefined
at Object.<anonymous> (src/email/email.service.ts:1877:43)
我希望将config定义为config模块的默认导出
环境:
node-config version: config@3.2.4
node-version: 12.13.1
tsc -v
Version 3.7.4
ts-jest@24.3.0
而不是
import config from 'config'
写这个
import * as config from 'config'
而不是
import config from 'config'
写这个
import * as config from 'config'