-
Notifications
You must be signed in to change notification settings - Fork 656
Proposal: Pass expect
as a param in bdd tests
#6541
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
Comments
Of the options, I like 3 the best. It seems least intrusive. I can implement this if approved. |
Would it be unreasonable to support As in
If that should be supported, then I believe that |
Currently Regardless, I think it makes more sense to have that sort of info in the |
Sounds good, and do feel free to ping me whenever you'd like a review or a second opinion. |
@std/testing
versions of TestContext
and expect
@std/testing
versions of TestContext
and expect
@std/testing
versions of TestContext
and expect
expect
as a param in bdd tests
Uh oh!
There was an error while loading. Please reload this page.
Is your feature request related to a problem? Please describe.
Leads to natural solutions to
expect.hasAssertion
andexpect.assertions
silently pass outside bdd tests #6518:expect
outside@std/testing
tests will not have the methods that are failingexpect.hasAssertion
andexpect.assertions
pollute other assertions tests #6540: Replacing the globalAssertionState
with one passed in the context guarantees assertions are counted in the right context, and possibly in parent contextsDescribe the solution you'd like
interface ItTestContext extends Deno.TestContext
which can include anAssertionState
it
andtest
useItTestContext
instead ofDeno.TestContext
@std/expect
'sexpect.hasAssertion()
andexpect.assertions()
to prevent them from being used outsidebdd
testsexpect
from abdd
testexpect.hasAssertion()
andexpect.assertions()
Options for syntax:
Describe alternatives you've considered
I don't see a way to improve #6518 without movingAssertionState
to some sort of context: The alternative is to add some sort of way forexpect
to know whether it's being called in abdd
test. If not, it would need to avoid counting assertions, and throw in the assertions test functions.There might be a way for #6518 to be fixed by having it track whether it's been cleaned up and throw if not. The cleanup would happen in bdd tests but not in raw
Deno.test
s.For #6540, the direct issue can be solved by only throwing the error after cleanup. However, I think it's still unintuitive that the same
AssertionState
is used for multiple tests. Even Jest has this issue:More extreme alternatives could involve preventing
expect
from running outsidebdd
tests. This would prevent users from using different sources ofexpect
, but would also causeexpect
to be unavailable outsideDeno.test()
which is probably not a good idea.The text was updated successfully, but these errors were encountered: