How to check if object contains an item using Jasmine
<p>I am using karma and jasmine as my testing framework. This is my code:</p>

<pre><code>it('add() should add x to the reply object', function() {
    spyOn(ctrl, 'addxReply');
    ctrl.reply = {};
    ctrl.reply.post = 'test post';
    ctrl.add();
    expect(ctrl.addxReply).toHaveBeenCalled();
    console.log(ctrl.reply);
    expect(ctrl.reply).toContain('x');
});
</code></pre>

<p>This is my ctrl.add():</p>

<pre><code>self.add = function() {
    self.reply['x'] = self.posts[0].id;
    self.addxReply();
};
</code></pre>

<p>The problem is, when I run the code, this is what it returns:</p>

<pre><code>LOG: Object{post: 'test post', x: undefined}
Chromium 48.0.2564 (Ubuntu 0.0.0) Controller: MainCtrl add() should add x to the reply object FAILED
    Expected Object({ post: 'test post', x: undefined }) to contain 'x'.
</code></pre>

<p>As you can see, my reply object does contain <code>x</code> but the line <code>expect(ctrl.reply).toContain('x');</code> is still failing. Any idea how I can properly verify that my object contains a <code>x</code>?</p>