0

I am working on a Angular.js application with Bootstrap (and jQuery). I am using Karma Jasmine with PhantomJS for testing.

I have written a test that runs a method from my controller and compares two identical objects.

it('should have a showDialog method which prompts a crud dialog', function () {
  ctrl.showDialog({
    id: 123,
  });
  expect(ctrl.crudDialogData).toBe({
    id: 123,
  });
});

The showDialog() method stores the argument passed in to the crudDialogData property.

When running my tests I receive the following error:

Expected Object({ id: 123 }) to be Object({ id: 123 }).

As far as I can see, this should be a pass. Any help?

Adam McKenna
  • 2,295
  • 6
  • 30
  • 41

1 Answers1

2

toBe matches by reference. toEqual matches by value. Looks like you want to use toEqual

Related SO answer: https://stackoverflow.com/a/27929503/803739

Community
  • 1
  • 1
Terry
  • 14,099
  • 9
  • 56
  • 84