我目前正在开发一个使用NodeJS的TypeScript项目,并且正在尝试使用Mocha测试我的应用程序。我面临的主要问题是,当我试图让Mocha加载终端中的dotenv模块并将.env路径配置为:.env.test时,我会收到警告。
这是我使用的命令:
mocha -r ts-node/register -r dotenv/config 'tests/**/*.ts' dotenv_config_path=.env.test
在执行此命令时,Mocha向我发出以下警告:
Warning: Cannot find any files matching pattern "dotenv_config_path=.env.test"
但是之后,它成功地用.env.test路径加载了dotenv模块,并且它能够通过我的所有测试用例而没有任何错误。
有什么办法可以摆脱这个警告吗?或者什么是首选的设置,这样我就不会得到这个警告了吗?
发布于 2021-02-01 19:38:06
正如@jonrsharpe所指出的,在配置--
之前,我忘记了dotenv_config_path
。
现在完整的命令是:
mocha -r ts-node/register -r dotenv/config 'tests/**/*.ts' --dotenv_config_path=.env.test
https://stackoverflow.com/questions/65998899
复制相似问题