-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Add timeoutAfter method #132
Conversation
do you want a per test timeout or a global timeout ? You need external timeouts anyway, because anything can hang including resource leaks and infinite loops. What's the use-case for this ? |
@Raynos Per test preferably. The use case is any asynchronous code that might crash or fail to return for whatever reason. An example would be if you work with any kind of event driven or streaming code, and you want to test that: if you mess up but don't have timeouts the test will just stop at the particular example that doesn't work and never fail and continue to the other tests. |
@FredrikNoren the same holds for any other failures like thrown exceptions or infinite loops, it just halts your code. |
@Raynos I guess it's probably a matter of taste but exceptions are handled as failures in mocha. Infinite loops are hard to get around if it's the same process though. The reason it might be advantageous to fail the tests is that if you fail them the rest of the tests will still run, so if one of the tests fails early on you can still know that everything else works. The way it is now it will just halt and you don't know if it's just this one test that fails or if all your tests fails (which might be completely unrelated to that first test which fails). |
@FredrikNoren I think this feature is legit. Do we have a preference between
And
I favor the later as we already use that for { skip: true } |
@Raynos either is fine for me. I guess it would probably even be pretty easy to support both (i.e. |
@Raynos added support for it to the PR |
I have a preference for not extending the public interface of I have a seperate PR that is trying to make the public interface of We can support both, but it is nice to only have one interface. |
let's leave the method in place and document the { timeout: 5000 } option in the README then its good to go. |
@Raynos Cool, I added |
@FredrikNoren sweet, thank you :) |
@Raynos Thanks for the quick release! |
To automatically timeout long running tests