title: Access to Context API from outside of the component being tested
body: <p>I'm using Jest and React-testing-library to test a React component. I've rendered a component with a Context API Provider so the component has access to the Context. Unfortunately, I don't know how could I access it from outside the rendered component. In this case there is an <code>isUserLogged</code> property in the Context depending on which the component changes. But I don't know how could I change the value of this property. How could I approach this case? If mocking of the Context API required how could I do it?</p>
  
  <p>In the attached code I try to access a Context using a useContext hook. The error says I can't use hooks outside of React components. And, obviously, I'm trying to access the Context outside the Context Provider so it wouldn't work anyway.</p>
  
  <pre><code>import { Provider, Context } from '../../context';
  
  test('Star is not clickable for a non-registered user', () =&gt; {
    const { getByTestId } = render(&lt;Provider&gt;&lt;Star /&gt;&lt;/Provider&gt;);
    const isUserLogged = useContext(Context).isUserLogged; // Error.
  });
  </code></pre>