I refactored almost 30 tests that were using try/catch to check if an error had been thrown. There are two problems with this approach:
It's unnecessarily complex. We can easily replace these try/catch-based assertions with t.rejects.
But the worst issue is: without using t.plan(), these tests would pass even if the error wasn't thrown. And most of these tests weren't using t.plan. In fact, 4 tests were passing without the exceptions they test for being thrown. Out of these 4, I was able to confirm that at least 1 was obsolete, so I've removed it. The other 3 tests remain untouched (test/app-decorator.js:476, test/loaders:529 and test/routes:964).
I refactored almost 30 tests that were using try/catch to check if an error had been thrown. There are two problems with this approach:
t.rejects
.t.plan()
, these tests would pass even if the error wasn't thrown. And most of these tests weren't usingt.plan
. In fact, 4 tests were passing without the exceptions they test for being thrown. Out of these 4, I was able to confirm that at least 1 was obsolete, so I've removed it. The other 3 tests remain untouched (test/app-decorator.js:476
,test/loaders:529
andtest/routes:964
).closes #995
FYI: @simoneb