Actually fail tests when function in question does not throw error as expected
Actually fail tests when function in question does not throw error as expected
Fix #2790 (closed)
Added TestError
which we can throw whenever we do the assert.fail(new TestError('...'));
and then know it's the only special error we need to re-throw to fail the test.
const TestError = require('gitter-web-test-utils/lib/test-error');
try {
someFunction();
assert.fail(new TestError('expected error to be thrown'));
} catch (err) {
if (err instanceof TestError) {
throw err;
}
assert.ok(err);
}
Dev notes
Places of interest
assert(err
assert.ok(err
assert.ok(false
assert.fail(
Affected tests
-
modules/cache-wrapper/test/cache-wrapper-test.js#L36-42
-
modules/matrix-bridge/test/gitter-bridge-test.js
-
modules/matrix-bridge/test/matrix-utils-test.js
-
modules\matrix-bridge\test\matrix-event-handler-test.js
-
Related but mis-use of assert.throws
modules/gitlab/test/gitlab-user-service-test.js#L50-52
Edited by Eric Eastwood