-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Suggest new assertions on async rejection #507
Comments
This only works if you node itself has issues with their promise assertion helpers, namely that they need to force an await for work properly, but there's no wait to do that. What I would suggest is using normal promises:
|
Oh, I see your point. Thx. |
To be clear; node's The problem (one which node itself also has) is, what do you do if someone does |
Can you return a thenable from |
The user can do that - the problem is that tape can’t force the user to do so. Calling t.rejects in a test suddenly making the test wait on a promise sounds very strange to me, and we’d have to do some pretty complex acrobatics to combine multiple rejects/doesNotReject promise with the final promise the user may or may not return, including those of subtests. |
also, nextTick isn’t soon enough; the test promise might take many ticks to settle. |
I guess I am saying what if Basically make it return a Maybe that's not better, maybe that's worse. But it's an option. |
I guess I'm still not clear on what that would mean, a "blocking thenable". Even if we could detect the "fail" case (where the promise does not reject) when the test ends, we couldn't detect the "succeed" case (where the promise does reject). |
I have been hurt by forgetting await before t.rejects. Also I need to explain to co-worker why Appreciate if the tool can point out the direction in error message, which is probably the best we can do here, if it's possible. |
If node is incapable of improving the experience here, I'm not sure how we can :-/ |
That is no different from: t.rejects(someSync())
console.log(throws())
window.addEventListener('load', onload()) // <-- notice it's called While they're annoying, they're entry-level errors and there's nothing the engine or other tools can do (except TypeScript in some cases). As far as Tape or Node is concerned, that line of code isn't any different from const v = await someAsync();
t.rejects(v) or just throw new Error();
t.rejects(v) |
Following up #472 (comment)
Suggest to add the two assertions (or something similar) from tape-promise https://github.com/jprichardson/tape-promise#new-assertions
It would not change the existing behaviour, as the two assertions are async.
Example from tape-promise:
The
await
is on the assertion, not on the input of the assertion. It reads "The input promise will eventually reject".Right now I am using following code to migrate from tape-promise to tape v5.
The text was updated successfully, but these errors were encountered: