I have a __mocks__
folder with a file called example.ts
in it
File Content (shortened for simplicity)
export let token: string | null = "exampleString";
I have a test file where I use this variable in all the test cases.
There is one in particular where I want to override the value of this variable to be null
Approaches tried:
- Use a proxy to try to intercept the variable when the function to be tested is called (no success, variable still set to
exampleString
- Use jest.spyOn to try and override the variable, still no success
- Used
jest.unmock('../../modules/__mocks__/example');
to try and use the real implementation of the file but no success
Has anyone got an idea on how to successfully override the value of the variable for a single test case?
Thanks
Via Active questions tagged javascript - Stack Overflow https://ift.tt/zv5wiGK
Comments
Post a Comment