-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
How to mark a deferred case as failed? #43
Comments
Hm I'm not sure why would you want that unless you want to optimize speed of throwing errors :) In case you only want to know that something went wrong, you can also open inspector in your browser and error should be logged there. I'm not sure why testing process for deferred tests does not exit on error. I'll take a look. v1.1 should be started soon. |
I don’t want to test expected errors. My example is just an example. At the moment I have few options to deal with errors:
I’ve addressed the question to benchmark.js, thanks.
I agree, but it’s not always possible because:
It’s a bad UX and not always possible, e.g. in Chrome on iOS. |
start on v1.1 will be very soon, so I'll include this on the list and try to see it in more detail. JSBenchme development is kinda cyclic. Once or twice a year I batch all the features/bug requests and do them all at once. So I really cannot say much more about this from the top of my head. It's been months. But it seems a reasonable request to make it impossible for test to hang, even if it is a benchmark.js issue (any maybe it's not). |
@psiho Ok, thank you |
This turned out to be more complex than I thought. Benchmark.js just doesn't handle deferred errors. It handles regular ones ok, but deferred... not at all. But thanks to user 'kevinoid' at bestiejs/benchmark.js#123 I saved some time and just implemented solution similar to his. It's a bit hacky, but I think it's solid. Latest dev version is at https://dev--jsbenchme-v1.netlify.app/ so you can take a look and let me know if you need some tweaking, before v1.1 is published. |
@psiho How is asynchronous error supposed to be reported at https://dev--jsbenchme-v1.netlify.app/? I've tried these code snippets with defer mode, they never complete: new Promise(resolve => setTimeout(resolve, 100))
.then(() => {
deferred.reject()
throw new Error('Test')
}) setTimeout(() => {
deferred.reject()
throw new Error('Test')
}, 100) |
@Finesse , I was testing with something like your 2nd example and if you run that one alone it will throw error (and continue running other tests if any). Error thrown is and displayed in UI is: As for the first example, it's interesting to see why this one was not caught by UI. Error is output to console, but somehow it bypassed window.onerror. Will continue to tune this. |
@Finesse , oh, it seems this is just a different type of error and requires 'unhandledrejection' event listener on window. That catches those. New dev version v1.0.0-513 dev is up for you to try. |
@psiho Now both examples work 👍 But the second example prints |
Safari 14.0.3 on macOS 11. Probably, browsers use different security settings for accessing error messages. |
yup, tried it with Midori, closest I can get to Apple, and error object contains no mora data. I'll call it a day. Important thing is that this does not interfere with other tests, that they continue while failing test aborts and errors. We're all developers, console contains more details on errors. Closing this. Will probably go live over the weekend. |
Thank you! |
If a not deferred test case throws an error, the UI shows that the case has failed:
How can I mark a defer test case as failed similar to the example above? I tried
deferred.reject()
, but the function isn't defined.The text was updated successfully, but these errors were encountered: