Skip to content

Nicer way to check how many times a function has been called #64

@LeaVerou

Description

@LeaVerou

This is one of the things hTest needs for parity with other testing frameworks, and can be quite useful for testing events etc.

One way to implement it would be a predefined run function that tests can import, but the count needs to be specific to the test.

Perhaps this can be done if the function maintains a weakmap of Test objects to counts? Or it can also use data to store the count?

But then how do you signal that the test is over? You want to fail when it's called both fewer times, and more times than you want, so using a promise that resolves when it's been called as many times as expect specified doesn't seem to fly.

Looks like we need a timeout for async tests (if we don't already have one), but that by itself is not enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions