-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: introduce fail
function
#123
Conversation
colors/test.ts
Outdated
@@ -7,17 +7,13 @@ test(function singleColor() { | |||
}); | |||
|
|||
test(function doubleColor() { | |||
assertEqual(color.red.bgBlue("Hello world"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file changed because i ran prettier across it FYI
I know this is part of #122, but perhaps we could discuss the renaming independently of this. IMO assertThrows(fn, err?) throwing an assertion error (optionally of type/equal to err) seems desirable. |
It depends really on what our aim is with naming of test functions. If we agree on following the pattern of all assert* functions asserting, and all unprefixed functions returning bools then yes we should have an assertThrows (alongside the boolean unprefixed function). It'd be three args in that case, If however we did end up following node and making all functions assert, there'd just be the one function with the assertion added inside. |
I think it makes sense to move asserts to the node-style API. I wrote the asserts lib - so biased. Let's do the reorganization to a Node-style API later - and after others have had a chance to chime in (ping @piscisaureus) |
Do note that this pr defines it as a boolean function to be used with the assert function. So if we rename it, we also want it to throw like assert does, right? |
Remove it please |
Sorry for the double PRs (#124) but I mention in the other PR that I already had something on my local machine because I was frustrated last night when writing some tests. I think we should decorate assert with additional functions, as that is more common. My PR also has a few more features that brings it in line with something like Chai for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting feature!
anyhow, updated this to be just |
@ry |
@43081j Oops - can you rebase once more? LGTM |
@ry rebased |
fail
and throws
functionsfail
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks : )
Introduces these two:
For now,
throws
returns a boolean and is expected to be used withassert
just likeequal
.If we want node compatibility, see #122 (
throws
does the assertion and throws the assertion error in node rather than returning a bool).