title: How to use toEqual(...) with AngularJS promise data?
body: <p>When authoring AngularJS resource factories via <a href="https://docs.angularjs.org/api/ngResource/service/$resource" rel="nofollow">the <code>$resource</code> service in the <code>ngResource</code> module</a>, the return values of the action methods are objects with additional properties <code>$promise</code> and <code>$resolve</code>.  What is the preferred way to strip or ignore those properties so that they can be compared to sample data using <a href="http://jasmine.github.io/2.0/introduction.html#section-Included_Matchers" rel="nofollow">the Jasmine <code>toEqual(..)</code> matcher</a>?</p>
  
  <p>For example, I might have specs that look like this:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>describe('the #query() action method', function() {
    var mockData;
    beforeEach(function() {
      mockData = [1, 2, 3];
      $httpBackend.when('GET', '/foo').respond(200, JSON.stringify(mockData));
    });
    it('returns the mock data', function() {
      var queryData = MyResource.query();
      $httpBackend.flush();
      expect(queryData).toEqual(mockData);
      // ^-- Fails since "queryData" has properties $resource and $resolve.
    });
  });
  </code></pre>
  
  <p>Currently I am working around by inserting the following line before calling the matcher but this feels like a kludge:</p>
  
  <pre><code>queryData = JSON.parse(JSON.stringify(queryData));
  </code></pre>
  
  <p>Is there a better/preferred way to compare promise data which ignores the added properties?</p>