I'm currently working on a NodeJS project that uses TypeScript, and I'm currently trying to test my application using Mocha. The main issue I am having is that I am getting a warning when I am trying to get Mocha to load the dotenv module in the Terminal and have the .env path be configured to: .env.test
This is the command I used:
mocha -r ts-node/register -r dotenv/config 'tests/**/*.ts' dotenv_config_path=.env.test
When executing this command, Mocha gives me the following warning:
Warning: Cannot find any files matching pattern "dotenv_config_path=.env.test"
But afterwards, it successfully loads the dotenv module with the .env.test path, and it's able to go through all my test cases without any errors.
Is there any way to get rid of this warning? Or what is the preferred setup so that I wouldn't get this warning to begin with?
As @jonrsharpe had pointed out, it turns out that I forgot the --
before configuring my dotenv_config_path
.
The complete command now is:
mocha -r ts-node/register -r dotenv/config 'tests/**/*.ts' --dotenv_config_path=.env.test