title: Why is my expect().to.have.property() passing even though property is not present?
body: <p>I'm trying to write tests of my node.js api but encountered a problem when trying to test for a property.
  My application is using mongoose. I'm selecting data from mongodb using:</p>
  <pre class="lang-js prettyprint-override"><code>User.findById(req.params.id).select('-refresh_token -password -_id');
  </code></pre>
  <p>Response from the query is:</p>
  <pre class="lang-json prettyprint-override"><code>{ 
      login: 'asd', 
      email: 'asd@example.com', 
      role: 'user', 
      __v: 0 
  }
  </code></pre>
  <p>In my test file I'm using mocha and chai to write integration tests and have a test structured like this:</p>
  <pre class="lang-js prettyprint-override"><code>let response = await UsersController.getUser(req);
  console.log(response._id);
  expect(response).to.be.a('object');
  expect(response).to.have.property('_id');
  </code></pre>
  <p><code>UsersController.getUser(req)</code> returns the result of the query so I expect it to not have <code>_id</code> property.
  When I try to console log it I get <code>undefined</code> but my test passes without any problem. When I console log entire response it does not appear to have <code>_id</code> property (as expected).</p>
  <p>When I test for another property that certainly isn't in my response (e.g. for property <code>asdasdas</code>) the test fails.</p>
  <p>EDIT</p>
  <p>When I add <code>expect(response).to.not.have.property('_id')</code> my test fails.</p>