【发布时间】:2023-04-02 22:07:02
【问题描述】:
process.env 变量在运行yarn run jest 时显示未定义。我已将每个配置变量存储在我的 local.settings.json 文件中,并且它在正常调试中运行良好。
我的代码是这样的:
local.settings.json:
{
"IsEncrypted": false,
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
},
"Values": {
"IOTHUB_CONNECTION_STRING": "xxxxxxxxxxxxxxxxxx",
"AZURE_DEVOPS_URL": "xxxxxxxxxxxxxxxxxxxx"
}
}
jest.config.js:
module.exports = {
log: jest.fn(),
}
天蓝色 httptrigger 函数 - index.js:
const iothubConnectionString = process.env["IOTHUB_CONNECTION_STRING"];
console.log( iothubConnectionString ) //undefined
由于这些配置变量,我的测试失败了。我需要通过考试。谁能帮帮我。
【问题讨论】:
-
请不要使用图片来分享您的代码。编辑您的问题并将代码直接包含在您的问题中。
标签: node.js azure jestjs azure-functions