summary
As rarely used as it is, Mocha currently supports marking a test as failed after it has already completed.
As an example, here is a unit test from mocha's own suite (src):
describe('fail the test from the "after each" hook', function() {
it('should fail', function() {
// but not here
});
afterEach(function() {
this.test.error(new Error('failing from after each'));
});
});
summary As rarely used as it is, Mocha currently supports marking a test as failed after it has already completed.
As an example, here is a unit test from mocha's own suite (src):
This code branch needs to call
karma.report
in the case oftest.type === 'test'
: https://github.com/karma-runner/karma-mocha/blob/537ef7bafb2a1c78c32ba9d54ca3bef877c52c34/src/adapter.js#L164-L171Is this something maintainers would be willing to accept a PR on?
Thanks!