-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
-
If a function
fthrowsErrorB,assert.throws(f, ErrorA)andassert.notThrows(f, ErrorA)should signify the actual (ErrorB) and expected (ErrorA) errors rather than just throwingErrorB -
ErrorBis also swallowed as anAssertionError, rather than its true error type. For example, if there is aTypeErrorinsidef, theTypeErrormessage will be thrown as anAssertionError.
const f = function() { const x = 5; x = 6; }
// what currently happens
// AssertionError: Assignment to constant variable
assert.throws(f, ErrorA);
// AssertionError: Got unwanted exception
assert.notThrows(f, ErrorA);
// what should happen
// AssertionError: you caught the wrong exception (actual: TypeError, expected: ErrorA)
assert.throws(f, ErrorA);
// AssertionError: f threw an unwanted exception (actual: TypeError, expected: ErrorA)
assert.notThrows(f, ErrorA);Metadata
Metadata
Assignees
Labels
No labels