Dotenv: Loading dot env file in Unit Testing

Created on 19 Apr 2017  路  3Comments  路  Source: motdotla/dotenv

Hi @motdotla ,

I'm writing unit test for my angular 2 app with jasmine + karma. Could you show me the way to load dot env to test component ?

Thanks
Nam

Most helpful comment

@motdotla on another note, how would you resolve the fact that we need to get, for instance, an auth token to execute the tests? The issue really is that each developer will get the auth token using their own account on Auth0, which requires several environment settings that should ideally not be shared between developers or committed to git. Any ideas?

All 3 comments

if your unit tests depend on something outside of the code you're testing, it's not a unit test 馃榿

@maxbeatty is right, but if you are looking for some ways to solve your problem, take a look at this thread: https://github.com/motdotla/dotenv/issues/184

@motdotla on another note, how would you resolve the fact that we need to get, for instance, an auth token to execute the tests? The issue really is that each developer will get the auth token using their own account on Auth0, which requires several environment settings that should ideally not be shared between developers or committed to git. Any ideas?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndrewChen1982 picture AndrewChen1982  路  4Comments

AndersDJohnson picture AndersDJohnson  路  5Comments

ycmjason picture ycmjason  路  4Comments

marcusradell picture marcusradell  路  3Comments

shai32 picture shai32  路  5Comments