avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Have assertions return booleans #2455

Closed novemberborn closed 3 years ago

novemberborn commented 4 years ago

Spurred by conversation in https://github.com/avajs/ava/issues/2449 and https://github.com/avajs/ava/issues/1485 we'd like for our assertions to return booleans. true when they pass, false when they fail. This does not apply to the throws() and throwsAsync() assertions.

Failing assertions will fail the test, but do not throw exceptions. This means your test does not stop executing. Usually that's fine, but there are conditions where you're about to do something that uses a lot of resources, and it's already unnecessary. Returning booleans will help with this.

The assertions are defined here:

https://github.com/avajs/ava/blob/18aeac64db2711d37853175b5e8dc1fd72c66d2a/lib/assert.js#L238

The type definition should be updated to reflect the new return type:

https://github.com/avajs/ava/blob/18aeac64db2711d37853175b5e8dc1fd72c66d2a/index.d.ts#L41

Some tests should be added to (or existing test updated in) https://github.com/avajs/ava/blob/master/test-tap/assert.js.

aviralch commented 4 years ago

Hello,

can i work on this ?

novemberborn commented 4 years ago

@aviralch yea that'd be great, thanks!

pmascheroni commented 4 years ago

Hi, @novemberborn I am also attempting an update to this issue and wondering if I could be assigned to it too? Not sure if that is allowed, but I would like to work on this also.

Thanks

novemberborn commented 4 years ago

@pmascheroni let's give @aviralch a chance first.

aviralch commented 4 years ago

@novemberborn, @pmascheroni this is my first issue, I will try to do this and keep you updated by the end of of week.

BARICISSE commented 4 years ago

Hi, if no one is currently working on this and it is still open, i would like to contribute.

novemberborn commented 4 years ago

@aviralch what do you think?

aviralch commented 4 years ago

Yup, sure go ahead. I am currently in middle of exams but if you need to get in touch lmk.

novemberborn commented 4 years ago

Thank you @aviralch, and good luck!

RahulKannan12 commented 4 years ago

Hi, is it done ?, if not I can make a try ! Please let me know :+1: I would like to contribute

BARICISSE commented 4 years ago

Hi @RahulKannan12, I am currently working on it.

RahulKannan12 commented 4 years ago

Hi @BARICISSE , Okay great ! thanks for the information :+1:

HungryPandaBytes commented 4 years ago

Hello is this ticket still open? If not, I would like to grab this!

novemberborn commented 4 years ago

@mzzlillieee yes go for it.

jmarkham828 commented 4 years ago

@mzzlillieee @novemberborn Hey yo! :) I have a draft PR for this issue that I believe is almost there. @novemberborn need a little guidance on how to update the test file -- this is my first issue. Would you mind if I pushed up what I had if @mzzlillieee is busy?

HungryPandaBytes commented 4 years ago

@jmarkham828 No I don't mind. Something came up, so I won't be able to work on this issue until next week.

jmarkham828 commented 4 years ago

@mzzlillieee awesome! @novemberborn would you mind adding me to this issue so I can push?

novemberborn commented 4 years ago

would you mind adding me to this issue so I can push?

@jmarkham828 sure, but you don't need to be assigned an issue to create a PR 😉

rShar01 commented 4 years ago

Does this issue still a contributer?

novemberborn commented 4 years ago

@rShar01 this was picked up by @jmarkham828 quite recently, so maybe check in with them.

jmarkham828 commented 4 years ago

Will work on this PR #2564 more this weekend -- took me a while to tie up some projects at work, but am free to work Saturday and Sunday! Like I said, @novemberborn, I wasn't quite sure how to update the test file, what do you think?

adiSuper94 commented 4 years ago

@novemberborn , I'd like to take a crack at this issue. If @jmarkham828 is no longer active.

novemberborn commented 4 years ago

@adiSuper94 both you and @Davidmh93 have expressed an interest. And we haven't yet heard back from @jmarkham828 but that's OK. I think if either of you could take their commits and add on top of them, based on my feedback in #2564 that'd be great. And then you could help each other as well if need be. Does that sound all right?

dmanit commented 4 years ago

I'm unable to pick this one up now sorry

shailenpatel1 commented 3 years ago

Can I work on this?

novemberborn commented 3 years ago

@shailenpatel1 maybe you could pick up where https://github.com/avajs/ava/pull/2586 left off?

novemberborn commented 3 years ago

Merged in https://github.com/avajs/ava/pull/2696.