title: Jest test .toBeInstanceOf(Error) fails
body: <p>I have trouble checking whether promise rejects with error in Jest test. </p>
  
  <p>(post Jest 20 version:)</p>
  
  <pre><code>  test("Rejects on error", () =&gt; {
      expect.assertions(1);
      return expect(promiseHttpsGet(null)).rejects.toBeInstanceOf(Error);
    });
  </code></pre>
  
  <p>(pre Jest 20 version)</p>
  
  <pre><code>  test("Rejects on error", () =&gt; {
      expect.assertions(1);
      return promiseHttpsGet(null).catch((err) =&gt; {
        expect(err).toBeInstanceOf(Error);
      });
    });
  </code></pre>
  
  <p>I have tried both versions but Jest test fails with:</p>
  
  <pre><code>Expected value to be an instance of:
    "Error"
  Received:
    [Error: connect ECONNREFUSED 127.0.0.1:443]
  Constructor:
    "Error"
  </code></pre>
  
  <p>And the promise returning function is:</p>
  
  <pre><code>function promiseHttpsGet(url) {
    return new Promise((resolve, reject) =&gt; {
      https
        .get(url, (response) =&gt; {
          let responseBody = "";
          if (response.statusCode !== 200) {
            reject(response.statusCode);
          }
          response.setEncoding = "utf8";
          response.on("data", (data) =&gt; {
            responseBody += data;
          });
          response.on("end", () =&gt; {
            resolve(responseBody);
          });
        })
        .on("error", (error) =&gt; {
          reject(error);
        });
    });
  }
  </code></pre>
  
  <p>Any leads how to solve it?
  Thanks.</p>