t.notThrows(promise) should return an "empty" promise
See original GitHub issueThis is as expected:
const value = Symbol()
t.notThrows(() => value) === undefined
However:
const value = Symbol()
(await t.notThrows(Promise.resolve(value))) === value
t.notThrows(promise)
should return a promise, but for an undefined
value.
The offending line is at https://github.com/avajs/ava/blob/dcdfbee689e1538420f5793bbaca09c7e78ddedd/lib/assert.js#L124.
The Flow and TypeScript definitions should be updated too:
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Returning empty promise - javascript - Stack Overflow
For this input @Input() callback: () => Promise<null>;. there is no guarantee that it's assigned to proper value.
Read more >Empty Promises: Dos and Don'ts of ES6 Promises
What follows, are three tips for using promises more effectively. Chain, don't nest. When I first started playing with promises, I found myself ......
Read more >Should.js API Documentation
Assert given promise will be fulfilled with some expected value (value compared using .eql). Result of assertion is still .thenable and should be...
Read more >Behavior of empty promises in Node.js | by Elena Sharovar
Dear Node.js I did not expect this: if we do await [number] output is as expected: (async function main() { console.log('STARTED')
Read more >Assert | Node.js v19.3.0 Documentation
All errors thrown by the node:assert module will be instances of the AssertionError ... doesNotReject() will return a rejected Promise with that error....
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 Free
Top 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
IMO the parallel should be with the the form of
notThrows
that is passed a function:Is that a sensible thing to do, or is it not? Currently it doesn’t work, and we should resolve that inconsistency one way or the other.
I would rather say:
vs
I think the former, while a tiny bit more verbose, is much clearer.