Skip to content

Tag: javascript

Jest: How to undo a global mock for certain tests in a file

I want to mock Math.random for certain tests and use its original implementation for other tests. How can I achieve this? I’ve read about using jest.doMock and jest.dontMock, but I’ve bumped into a number of issues using them, like: I seem to need require in order to use doMock and dontMock, but m…

How to replace jsp tag with HTMLRewriter

I am kinda new to Cloudflare’s HTMLRewriter function. I am trying to replace a jsp tag with some html using HTMLRewriter. More precisely, <%= “${header}” %>. Is there a way I could possibly do this? I managed to replace a header tag <header>, but not jsp or some other string. Ans…