【发布时间】:2020-05-02 12:47:04
【问题描述】:
我有一个可用于开发和生产的打字稿模块。它使用https://github.com/lorenwest/node-config 我正在尝试将它导入到 jest 中以编写测试,它会抛出一个错误,表明配置对象未定义
TypeError: Cannot read property 'get' of undefined
at Object.<anonymous> (src/email/email.service.ts:1877:43)
来自
import config from 'config'
console.log('**********CONFIG GET*********', config); // undefined
const sendgridToken: string = config.get('socialApi.value') // throws error
我希望 config 被定义为配置模块的默认导出
环境:
node-config version: config@3.2.4
node-version: 12.13.1
tsc -v
Version 3.7.4
ts-jest@24.3.0
【问题讨论】:
标签: javascript node.js typescript jestjs