Using mocha for typescript tests

Errors like field is undefined (runtime error), or assert is failed.
I think adding a code example is the first thing people will ask for
Asserts work by throwing exceptions; Mocha doesn't actually know about the asserts, it just catches the exceptions and uses their info for the test failure. Exceptions inside a promise turn into promise rejections. Mocha can't know about those if you're not returning the promise -- in fact, it can't even know to wait for the promise code to complete in that case. But if you return the promise Mocha will wait for it and detect those rejections as test failures.
The relevant section in the documentation is here, for what it's worth: https://mochajs.org/#working-with-promises Although you don't generally need to know about the done callback if you're using promises, as returning the promise is usually the simpler alternative.
It sometimes feels as if enforcing the usage of done when a Promise is not returned would help people.
I'm going to start labeling common mistakes, so we can see the bigger picture whenever we need to.
Yep, returning promise it 'it' do the trick! Mocha detects all fails in then() and test failes! Thank you.
Most helpful comment
Asserts work by throwing exceptions; Mocha doesn't actually know about the asserts, it just catches the exceptions and uses their info for the test failure. Exceptions inside a promise turn into promise rejections. Mocha can't know about those if you're not returning the promise -- in fact, it can't even know to wait for the promise code to complete in that case. But if you return the promise Mocha will wait for it and detect those rejections as test failures.
The relevant section in the documentation is here, for what it's worth: https://mochajs.org/#working-with-promises Although you don't generally need to know about the
donecallback if you're using promises, as returning the promise is usually the simpler alternative.