chai icon indicating copy to clipboard operation
chai copied to clipboard

expect().should should warn

Open CoderFF opened this issue 5 years ago • 1 comments

I think, this is a good idea to warn because when someone types lots of ordinary .should assertions

message.id.should.be.equal(...);
message.user_id.should.be.equal(...);

and then suddenly they need to insert expect() assertion, it's easy to automatically type

expect(message.text).should.be.equal('test');

instead of

expect(message.text).to.be.equal('test');

When this happens, the error looks like this:

AssertionError: expected { Object (__flags) } to equal 'test'

Which looks like the message.text field is a strange object and can lead the developer on the wrong path.

CoderFF avatar Sep 01 '20 05:09 CoderFF

Sounds like a task for https://github.com/turbo87/eslint-plugin-chai-expect.

siddharthvp avatar Feb 14 '21 08:02 siddharthvp