Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing from test.after.each() makes otherwise failing test pass #201

Open
aral opened this issue Mar 19, 2022 · 1 comment · May be fixed by #196
Open

Throwing from test.after.each() makes otherwise failing test pass #201

aral opened this issue Mar 19, 2022 · 1 comment · May be fixed by #196

Comments

@aral
Copy link

aral commented Mar 19, 2022

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()

Result:

❯ node index.mjs

  (0 / 1)

  Total:     1
  Passed:    0
  Skipped:   0
  Duration:  1.03ms
@jmcdo29
Copy link

jmcdo29 commented Mar 20, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants