-
Notifications
You must be signed in to change notification settings - Fork 1.4k
BUG: test.cb('', async(t) => {}) throws wrong error notification [or test.serial.cb when awaited] #2383
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
Comments
This is intentional. For example, if a The last use for |
@sindresorhus @novemberborn There are rare cases where callback APIs are favorable, I think the example above is one of them. If I promisify it, then error handling becomes worse with try/catch on testing error scenarios, becomes much worse at being able to test multiple error scenarios at once, there are also rare cases where this is better than having a test case for each error. By deprecating test.cb() or making it legacy you are also disallowing the usage of promise.catch(() => {}) because there is no t.done() on normal test()’s. |
We won't be changing this behavior. |
ok, can we remove the API(test.cb and test.serial.cb), or deprecate it with a clear deprecation message? |
I'd say these are legacy APIs, not quite deprecated. Perhaps we can change the message? Something like:
|
Yes thats more clear 👍 However I think it would be even better if we remove or deprecate the methods(test.cb and test.serial.cb) altogether since callback based legacy apis can be promisified, current cb() implementation is very limited without async/await and there would be less documentation, learning and testing surface. |
version: 3.1.0
Code below gives an irrevelant error, and test fails while it shouldnt:
When I turn await fs.readFile to fs.readFileSync() it works so this is definitely a bug!
I guess this is happening because async function()'s have
return Promise()
during runtime. Such error/return check makesasync
keyword impossible ontest.cb()
andtest.serial.cb()
, which should be allowed in my opinion and current check isn't backwards-compatible because this behavior used to be allowed previously.The text was updated successfully, but these errors were encountered: