jasmine test a Restangular response

Issue

I’m calling

Restangular.all('resource').getList() 

and I want to test that the results are as expected.

In my test, I want to make this work

expectedResp = { one: 1, two: 2, three: 3 };
expect(resp).toEqual(expectedResp);

The problem is that the resp from restangular is restangularized, meaning it contains a bunch of members in addition to the data returned from the rest call.

Solution

It should be

expectedResp = { one: 1, two: 2, three: 3 };
expect(resp).toEqual(jasmine.objectContaining(expectedResp));

Answered By – Estus Flask

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.