Skip to content

Add expect_assertions(n) #2272

@schloerke

Description

@schloerke

When using callbacks (or async promises), it is nice to know that the callback was actually reached. With expect_assertions(n), you could declare the count of assertions at the top of a function and the remaining amount of expectations would be counted.

Implementation ideas:

  • Could use the$test_expectations value to set and check the total.
  • Might be useful to only set the method once.

Related: https://jestjs.io/docs/expect#assertion-count

Example implementation that does not have access to the$test_expectations: https://github.com/rstudio/promises/pull/192/files#diff-6481dd5af605948a35f35754a60e76df1c572fed58f647c29822fa5861eac1b9R148-R207
Example usage: https://github.com/rstudio/promises/pull/192/files#diff-f6895bf7784e973143ddcff9843efa2f831fba8ece0589789bd66bf6fd9e4ed1R14-R24

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions