avrelian/jasmine2-custom-message

Unexpected Behavior: Shows error message instead of failing expectation + message

Closed this issue · 3 comments

When I use this library, it shows me the custom error message but suppresses the details of why it failed (i.e. Expected Object({ name: 'test' }) to be null). It would be extremely helpful to see the reason it failed in addition to just the custom error message.

I think this feature is not worth it, since you can achieve it's aim by simply doubling your test case:

describe('test', function() {
  it('should be ok', function() {
    since('custom message')
    expect(3).toEqual(4); // => custom message

    expect(3).toEqual(4); // => ordinary jasmine message
  });
});

Nevertheless, I am open for any pull requests.

@avrelian @richardm @grayarch There is a PR to handle parsing #{message} when passing in a string parameter. This is not needed if passing in a function. The following example works right now with version 0.8.4:

function getAugmentedExpect(specialContext) {
  return since(function() {
    return `${this.message} with my own special context: ${specialContext}`;
  }).expect;
}

@avrelian you mentioned having to save off the original message, data.message, somewhere, but I did not need to do that because formatString is called before data.message is reassigned.

The feature is shipped in v0.9.0