Skip to content
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

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

Open
LeaVerou opened this issue Jan 22, 2025 · 0 comments
Open

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

LeaVerou opened this issue Jan 22, 2025 · 0 comments

Comments

@LeaVerou
Copy link
Collaborator

LeaVerou commented Jan 22, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant