I'm trying to contribute to the Payload repo by fixing an issue I reported. I already forked the project but I don't have MongoDB installed on my local machine, I use a remote MongoDB instance for my local development. So when I run
yarn dev admin I get an error because it is trying to connect to a local instance of MongoDB.
Is there a way to use a
.env file to set the MONGO_URL? I see that the
dev.ts does use the
process.env.MONGO_URL environment variable but it doesn't load the variables inside my
.env, so every time I want to run a test, I have to write the full command:
MONGO_URL="my_instance_url" yarn dev admin
I know is not a big deal, but I guess it's more convenient to use a
.env file for that.
Currently, this is not possible with how we have it configured. In my mind, this would introduce variability into the tests unnecessarily.
We do have the ability to use a MongoDB memory server if you were to pass
NODE_ENV=test as the prefix. This obviously doesn't resolve your ask for loading an .env file, though.
@denolfe Understood! Thank you very much.
I found a way to do it by setting the variable from the start command, so no big deal. It was good enough for my current setup