DEV Community

The Project Alpha
The Project Alpha

Posted on • Updated on

Got an issue while running test with Jest on my typescript next js app

Hi everyone,

I had an issue while I was testing my next js app. My app needs some environment variables to get data. However, I didn't found a way to make my code work...

https://github.com/hugos29dev/the-Project-Alpha/issues/3

Can someone take a look to it...

Hugo

Top comments (2)

Collapse
 
kvsm profile image
Kevin Smith ๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ

You need to load your dotenv in your tests too. Try adding

beforeAll(async () => dotenvLoad())

...before your test.

Collapse
 
theprojectalpha profile image
The Project Alpha

Thanks,

it works with the code you proposed.

Hugo