morficus / cypress-dotenv

Cypress plugin that enables compatability with dotenv
53 stars 13 forks source link

Error when there is no .env file #7

Closed pedromateo closed 4 years ago

pedromateo commented 4 years ago

An error is returned when looping the object keys in case there is no ".env" file. Despite the last version I got from npm is different than the one I can find in GitHub, the problem is in this line: https://github.com/morficus/cypress-dotenv/blob/aa3d216405ed8f529babff0629db9820e03284d6/index.js#L23

Thanks for your time!

morficus commented 4 years ago

hey @pedromateo - thanks for opening a bug report. Could you paste the error you're getting please?

This plugin is designed specifically to let Cypress understand environment variables loaded in a .env file. Could you share your use case for using the plugin but not having a .env file in your project?

wywywywy commented 4 years ago

My use case is that in my local dev machine I use a .env file.

But in my CI pipeline, I want to use proper environment variables.

morficus commented 4 years ago

@wywywywy ah yeah, the CI case makes perfect sense. I'll try to issue a fix for this over the weekend.

pke commented 4 years ago

Is this fixed? I don't see where the code would have an error, that causes it to fail when no .env file is available.

morficus commented 4 years ago

no, this is not fixed yet. I was buried with work the past few weeks and haven't had a chance to take a look at it but also haven't been able to recreate the issue.

morficus commented 4 years ago

@wywywywy and @pedromateo - I was never able to recreate the issue but I did add some additional checks/guards and tests to protected against this potential issue.

give v1.2.1 a try and let me know if you still run in to the same problem.