why assert on an async callback
See original GitHub issueusing assert which throws an error if the data doesn’t match the parameters feels a little odd for a library with an async callback – why not call the callback with an error?
it feels very odd to protect myself from a crashing program with doing:
try {
pwd.verify(pass, hash, cb)
} catch (err) {
cb(err)
}
Rather than just
pwd.verify(pass, has, cb)
Would you be open to a PR changing the async methods to call the callback instead of throwing an AssertionError?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
assert.async() - QUnit API
assert.async() returns a callback function and pauses test processing until the callback function is called. The callback will throw an Error if it...
Read more >assertion inside a callback that was called by an async ...
Inside a it callback with the done parameter : Any async function taking callback as parameter and calling this very callback makes the...
Read more >Expect.assertions in async/await function - Stack Overflow
Expect.assertions(number) verifies that a certain number of assertions are called during a test. This is often useful when testing asynchronous ...
Read more >Testing Asynchronous Code - Jest
If you don't use promises, you can use callbacks. For example, let's say that fetchData , instead of returning a promise, expects a...
Read more >QUnit - Async Call - Tutorialspoint
assert.async() accepts call counts as a parameter. The callback returned from assert.async() will throw an Error, if it is invoked more than the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🔥 this is also why promises are terrible at error handling 🔥
@emilbayes thank you for this. this feels much better from an “end developer”