title: How to overcome jest "Cannot access before initialization" problem?
body: <p><strong>settings.js</strong></p>
  
  <pre><code>export default {
    web: {
      a: 1
    },
    mobile: {
      b: 2
    }
  };
  </code></pre>
  
  <p><strong>getSetting.js</strong></p>
  
  <pre><code>import settings from "./settings";
  
  export const getSetting = platform =&gt; {
    return settings[platform];
  };
  </code></pre>
  
  <p><strong>getSettings.test.js</strong></p>
  
  <pre><code>import { getSetting } from "./getSetting";
  
  const TEST_SETTINGS = { c: 3 };
  
  jest.mock("./settings", () =&gt; {
    return {
      test: TEST_SETTINGS
    };
  });
  
  test("getSetting", () =&gt; {
    expect(getSetting("test")).toEqual(TEST_SETTINGS);
  });
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>ReferenceError: Cannot access 'TEST_SETTINGS' before initialization
  </code></pre>
  
  <p>I believe this has something to do with hoisting. Is there a way to overcome this issue? Does jest provide any other means to achieve this?</p>
  
  <p>I don't want to do this. This is not good when the mock data is large and used in multiple tests.</p>
  
  <pre><code>jest.mock("./settings", () =&gt; {
    return {
      test: { c: 3 }
    };
  });
  
  expect(getSetting("test")).toEqual({ c: 3 });
  </code></pre>