tj / should.js

BDD style assertions for node.js -- test framework agnostic
MIT License
2.75k stars 194 forks source link

`rejectedWith` Gives GIANT unreadable message (for humans) when fails #232

Open robertleeplummerjr opened 5 years ago

robertleeplummerjr commented 5 years ago

I have a failing unit test that, when used with rejectedWith via:

describe('Super Getter', () => {
  it('should fail to 401', () => {
    return (new SuperGetter()).get().should.be.rejectedWith({ response: { status: 401 } });
  });
});

In the above simplified example, I'm getting a 403. the only thing I care about is if the response.status matches that of what the actual error is. But instead I get an 18,000 line message (it is actually longer) of the thing it is expecting. This is a gross overflow of information that nobody cares about and should be a simple 1 or 2 line of the following:

AssertionError: expected [Promise] to be rejected: expected error.response.status = 401, to match error.response.status = 403

Can this be simplified to valuable information?