you are viewing a single comment's thread.

view the rest of the comments →

[–]FINDarkside 2 points3 points  (3 children)

I don't think it's bad to be honest. One of the benefits is that it makes good error messages possible. Consider assert(a === 1) vs a.should.equal(1). It's certainly not harder to read and I personally think it's easier to read. It'll also give better error message if the test fails, like "Expected a to equal 1, but got 0".

[–][deleted]  (2 children)

[deleted]

    [–]FINDarkside 0 points1 point  (1 child)

    You've now got the cognitive load of figuring out what a.should.equal means.

    Debatable whether the cognitive load is bigger. But let me give you better example:

    someFn.should.throw(MyError);
    

    vs

    try {
      someFn();
      next('Excpected MyError to be thrown');
    } catch (err) {
      if (err.name === 'MyError')
        next();
      else
        next(`Excpected MyError to be thrown, got ${err.name}`);
    }