title: How to mock Json.stringify in jest test cases?
body: <pre><code>try {
              myObject = {
                  a: JSON.stringify(obj)
              };
          } catch (err) {
              logError(`myMethod :::: ${err.message}`);
          }
  </code></pre>
  <p>I wanted to cover catch block under jest testcases but I am new to this jest test cases so I m not getting how to mock Json.stringify and how to throw error?</p>
  <p>I am mocking as below. But I am getting error as: TypeError: Invalid JSON Can u please tell me where I am going wrong?</p>
  <pre><code>JSON.stringify = jest.fn().mockImplementationOnce(() =&gt; { throw new TypeError('Invalid JSON'); });
  </code></pre>