title: jest mock file's variables and change function behaviour
body: <p>I want to write test case for my router. I have const object which I want to mock during test case. How can I change the user object within the test file.</p>
  
  <pre><code>const user = {
    isAuthenticated: true
  };
  
  export const PrivateRoute = ({ component: Component, ...rest }) =&gt; {
    return (
      &lt;Route
        {...rest}
        render={props =&gt;
          user.isAuthenticated ? (
            &lt;Component {...props} /&gt;
          ) : (
            &lt;Redirect
              to={{
                pathname: "/login",
                state: { from: props.location }
              }}
            /&gt;
          )
        }
      /&gt;
    );
  };
  </code></pre>
  
  <p>test.js</p>
  
  <pre><code>it("should return login route", () =&gt; {
      const route = &lt;PrivateRoute path="/" component={()=&gt;{}} /&gt;
      expect(route)..toMatchSnapshot();
  });
  
  it("should return home route", () =&gt; {
      const route = &lt;PrivateRoute path="/" component={()=&gt;{}} /&gt;
      expect(route)..toMatchSnapshot();
  });
  </code></pre>