RSSAmplifier

Royal Icing — Patrick George Wyndham Smith · May 21, 2021

Mocking window.location in Jest

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

Mocking window.location in Jest It’s sometimes necessary to mock window.location in Jest tests. This could because you want to know when window.location.reload() is called, or one of its other methods ( .assign() , .replace() ). Here’s some code to achieve this: const savedLocation = window . location ; beforeEach ( () => { delete window . location ; window . location = Object . assign ( new URL (…

Read on royalicing.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.