dotenv-run icon indicating copy to clipboard operation
dotenv-run copied to clipboard

How to use with jest?

Open Voldemat opened this issue 2 years ago • 5 comments

TypeError: Cannot read properties of undefined (reading 'NG_APP_GRAPHQL_ENDPOINT')

  1 | export const environment = {
> 2 |     graphqlEndpoint: import.meta.env.NG_APP_GRAPHQL_ENDPOINT
    |                                      ^
  3 | }

  at src/app/environment.ts:2:38

Looks like @ngx-env/builder is not loaded, how I can setup env from code. I would probably put it in setupJest.ts file, where it will be loaded on jest startup.

Voldemat avatar Jun 22 '23 08:06 Voldemat

Yes, the same question

t-mish avatar Jan 31 '24 09:01 t-mish

same issue, no idea how to setup jest tests with this great library

pbintcha avatar Mar 02 '24 09:03 pbintcha

I've just released a package that should help with the setup. https://www.npmjs.com/package/@dotenv-run/jest-angular

Could you please give it a try?

chihab avatar Mar 02 '24 22:03 chihab