title: How to exit from jest test on some conditions check in beforeAll?
body: <p>I using Jest to run tests.
  I am starting a test server which uses tests table to do data insertion and read. So what I am trying to achive is first check in the <code>beforeAll</code> if the running environment is test or not as when I will deploy on server so that it won't run tests in the production db if some mistakes are there and the sever is not test server.
  So for this I have a an endpoint which gives the environment and I want to call that endpoint in <code>beforeAll</code> and then if the environment is test continue and execute the test cases other wise I don't want to run the test cases.
  How can I acvieve this in Jest?
  Below is the code I want to run but <code>return</code> or <code>throw</code> or <code>process.exit</code> nothing is exiting the test cases and all of the tests runs.</p>
  <pre><code>beforeAll(async () =&gt; {
    const GET_ENVIRONMENT_QUERY = gql`
      query GetEnvironment {
        getEnvironment
      }
    `;
    const loggedInClient = createApolloClientInstance(&quot;LOGGEDIN&quot;);
    const response = await loggedInClient.query({
      query: GET_ENVIRONMENT_QUERY,
    });
    if (response.data.getEnvironment !== &quot;TEST_&quot;) {
      console.log(&quot;Here it should exit&quot;);
      return;
    }
  });
  </code></pre>