title: How to unit test JSON result in Jest NodeJS?
body: <p>my function i am trying to unit test is given as</p>
  
  <p><strong>NOTE</strong> :   <code>mypayload= payload.Items</code> i will give a JSON reference at the end of the question</p>
  
  <pre><code>function setIdtoDeviceIdIfEmptyAndSetNullIfFieldEmpty(mypayload) {
        let _res = mypayload.map(ele =&gt; {
          if (ele.id == null) {
            ele.id = ele.deviceId
          }
          if (ele.id == null &amp;&amp; ele.deviceId == null) {
            ele.id = '***Both id and device id is null***'
          }
          if (ele.ssid == null) {
            ele.ssid = '***ssid is null***'
          }
          if (ele.deviceName == null) {
            ele.deviceName = '**deviceName is null**'
          }
          return ele;
        })
        return _res
      }
  </code></pre>
  
  <p>I am trying to test the <strong>most basic part</strong> that is the first if loop <code>ele.id==null</code></p>
  
  <p>I have tried : </p>
  
  <pre><code>describe('Test setIdtoDeviceIdIfEmptyAndSetNullIfFieldEmpty', () =&gt; {
          test('testing null', () =&gt; {
              index.setIdtoDeviceIdIfEmptyAndSetNullIfFieldEmpty(mypayload)
              mypayload.map(ele =&gt; {
                  if (ele.id == null) {
                      expect(ele.id).toEqual(ele.deviceId)
                  }
              })
          })
      })
  </code></pre>
  
  <p>However i cannot get this test case to fail for ex if i enter <code>expect(ele.id).toEqual("random")</code> it still passes when i am expecting it to fail,Clearly i am doing something wrong</p>
  
  <p><strong>Reference</strong></p>
  
  <pre><code>const payload = {"Items":[
      {
      "id" :"mycompany-00b12396",
      "ssid": "home",
      "deviceName": "mydevice",
      "time": "0.753235299 Hours"
      },
      {
          "ssid": "office",
          "deviceName": "thisdevice",
          "time": "12.52115515 Hours",
          "deviceId":"mycompany-0031f13"
      }
  ]}
  </code></pre>