See https://github.com/nodejs/node/blob/master/lib/assert.js#L305
Here, you test for !shouldThrow and expectedException(...).
In case of assert.throws() shouldThrow is always true and the above test will always fail, causing the instanceof test to never fail.
I think that the correct statement would be
if (shouldThrow && !expectedException(actual,expected))