title: How do I mock out location from the router when using enzyme
body: <p>I have the following code...</p>
  
  <pre><code> &lt;BrowserRouter&gt;
       &lt;Switch&gt;
           &lt;Route path='/' exact component={Main} /&gt;
           &lt;Route path='/transcript' component={Transcript} /&gt;
       &lt;/Switch&gt;
  &lt;/BrowserRouter&gt;
  
  // Inside Transcript...
  constructor(props){
      super(props);
      let params = new URLSearchParams(location.search);
      if(!params.get("id")){
          throw new Error("Transcript must have id");
      }
      ...
  }
  // Test
  describe("&lt;Transcript /&gt;", ()=&gt;{
      beforeAll(()=&gt;{
          context.trans = shallow(&lt;Transcript /&gt;)
      });
      it("Simple Test", ()=&gt;{
          expect(context.trans.find("audio")).toBeDefined()
      })
  });
  </code></pre>
  
  <p>When I try to run I get an error saying the param is missing. Now since I am not using the browser I am not sure how to mock this information. Specifically, how do I mock out the location.search variable?</p>