Ava: Remove ifError assertion?

Created on 18 Feb 2018  路  6Comments  路  Source: avajs/ava

Should we remove the t.ifError() assertion? It's functionally equivalent to t.falsy(). I suppose it's meant to be a "fail test if this variable contains an error" kind of assertion:

test.cb('look no error', t => {
  obj.asyncWithCallback((err, result) => {
    t.ifError(err); // Guard against there being an error
    t.is(result.value, 'bob'); // Now access `result`
    t.end(); // Aaaand done!
  });
});

This is odd though. t.end() can be passed an error, and besides we don't stop running the test implementation when an assertion fails so it doesn't do anything useful.

@avajs/core?

breaking good for beginner help wanted assertions

Most helpful comment

@novemberborn Gotcha! @kugtong33 you get first dibs!

All 6 comments

It was useful early on when callbacks were the main async thing and we didn't have as good assertion output as we have today. It doesn't make much sense today, so I agree we should remove it.

@kugtong33 since you reminded me to raise this, it's yours if you want it! 馃槈

@novemberborn To remove the ifError assertion, is it just removing it from the assert.js file?
https://github.com/avajs/ava/blob/master/lib/assert.js#L464

And potentially fixing any tests that uses the ifError?

Also, since it's a breaking change, what's the rules for versioning AVA?

@Jolo510 yup. The type definitions and documentation need to be updated sa well.

since it's a breaking change, what's the rules for versioning AVA?

We're currently doing 1.0 beta releases so there's no concern.

@novemberborn Gotcha! @kugtong33 you get first dibs!

@novemberborn @Jolo510 , on it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivogabe picture ivogabe  路  5Comments

niftylettuce picture niftylettuce  路  4Comments

sindresorhus picture sindresorhus  路  3Comments

leegee picture leegee  路  4Comments

pocesar picture pocesar  路  3Comments