Skip to content

Tag: mocking

Testing window.location in jest

I am trying to test the window functionality via jest. I have a function which appends a query param to the url and redirects the page to the other page. A rough snippet of the code is below: I am new to jest and I am facing a bit of difficulty simulating the mock test for this, hence can you

How to mock nanoid for testing?

I’m trying to mock nanoid for my testing but it doesn’t seem to be working. my function My test: So basically I’m struggling to figure out how to mock the nanoid which is generated inside the function. I’ve tried the following at the top of the file: however it doesn’t work at al…