Closed smelted-code closed 6 years ago
async function
just returns a promise, and promises never throw.
If you're testing that the promise succeeds, you can just return it to mocha/jest.
The challenge here is that your testing framework has to be able to support async assertions, and there's not really a reliable way for expect
(or any lib) to handle that.
You know, though I knew all those things, you saying it actually cleared it up a bit. As soon as the assertion framework starts supporting asynchronous code, it's going to start bleeding over into runner territory.
Thanks, closing.
I know that promises and the like have been brought up in the past with reference to assertions. Usually, mocha alone is sufficient. One thing I'm working with is async functions throwing:
Is there any interest in such a feature? Or is it anathema to make
TestUtils.functionThrows
async-friendly? I freely acknowledge that we can always do the time-tested try/catch/assert-in-catch-block method of testing things, but<subjective-statement>
it doesn't read as well.</subjective-statement>