So this had me scratching my head for a while today.
The following fails as expected:
import { test } from 'uvu'
function ouch () {
throw new Error('Oops!')
}
test('two wrongs do not make a right', async (context) => {
ouch()
})
test.run()
Result:
❯ node index.mjs
✘ (0 / 1)
FAIL "two wrongs do not make a right"
Oops!
at ouch (file:///home/aral/sandbox/uvu-test/index.mjs:4:9)
at Object.handler (file:///home/aral/sandbox/uvu-test/index.mjs:12:3)
at Number.runner (file:///home/aral/sandbox/uvu-test/node_modules/uvu/dist/index.mjs:77:16)
at Timeout.exec [as _onTimeout] (file:///home/aral/sandbox/uvu-test/node_modules/uvu/dist/index.mjs:138:39)
Total: 1
Passed: 0
Skipped: 0
Duration: 1.60ms
However, if you add an after.each() method that itself throws, the test run doesn’t fail (exits with a success status and without showing the error):
import { test } from 'uvu'
function ouch () {
throw new Error('Oops!')
}
test.after.each(() => {
throw new Error('The sky is falling.')
})
test('two wrongs do not make a right', async (context) => {
ouch()
})
test.run()
I think to an extent this may be related to #191. I can probably update my PR for that to include a fix for this too. Looks like the error isn't being properly reported
So this had me scratching my head for a while today.
The following fails as expected:
Result:
However, if you add an
after.each()
method that itself throws, the test run doesn’t fail (exits with a success status and without showing the error):Result: