How to override the default value of an ENV variable in a JestJS Unit Test while testing an exported component?
I am working on a NextJS+React project and need to write a Unit Test using JestJS that depends on one ENV variable. The variables is named to SITE_BRAND
and defaulted to brand
value.
How to properly mock cookies-next while testing with JestJS?
I need to test whether a component is rendered properly based on cookies. In the element are a few conditionals checking on some cookies values and outputting accordingly and this is what I am trying to test with JestJS.
Test that a function exported from inside a hook is called
I’m trying to test that a function, which is defined inside of a hook, is called in a component that uses that hook/function. I’m familiar with mocking simple modules/functions, but this scenario has me confused as I don’t know how to mock only a single returned function from that hook without losing all of the other functions/logic in that hook, which I don’t want to mock.