Expected object undefined using Jasmine toEqual

I’ve created a service to mask data and written a Jasmine test to compare actual and expected objects.
When I run the test I get undefined on the actual object returned from the service. Although when I console log it console.log(JSON.stringify(maskedData)); the maskedData is defined.

LOG LOG: '{"handle":"#######@#####.com","displayName":"####ane","iss":"####:###.###.##.#"}'
Expected undefined to equal <jasmine.objectContaining(Object({ handle: '#######@#####.com', displayName: '####ane' }))>.

Question:

Why does service return object evaluate to undefined in a test but defined in a console log?

I did think this could be an async bug hence the undefined value during test, but since console logging the value works I don’t think so.

This is a gist of the test in question:

const mockAddUserAction = {
    type: 'AddUser',
    payload: {
      handle: '[email protected]',
      displayName: 'tedJane',
      iss: 'http:192.168.12.1',
    },
  };

it('should mask PII user action.payload data with nested properties', async () => {
    const maskedData = service.maskPiiData(mockAddUserAction);
    console.log(JSON.stringify(maskedData));
    expect(maskedData.payload).toEqual(
      jasmine.objectContaining({
        handle: '#######@#####.com',
        displayName: '####ane',
      }),
    );
  });

Source: New feed
Source Url Expected object undefined using Jasmine toEqual