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

All subsequent tests will be skipped if throw non Error #229

Open
farwayer opened this issue Mar 21, 2023 · 4 comments
Open

All subsequent tests will be skipped if throw non Error #229

farwayer opened this issue Mar 21, 2023 · 4 comments

Comments

@farwayer
Copy link

farwayer commented Mar 21, 2023

Thanks for the nice lib! Just started using it and found a bug:

test('example', () => new Promise((resolve, reject) => {
  reject()
})

test('example', () => new Promise((resolve, reject) => {
  reject("reason")
})

test('example', () => {
  throw "reason"
})

As result test fail will be silently ignored. The bug is here: format function expects that err is defined and is Error instance although this is not required.

@farwayer
Copy link
Author

farwayer commented Mar 21, 2023

The problem is even more serious than I expected. All subsequent tests will be silently skipped. Even if the test itself worries about this problematic behavior, any third-party library that is used in the code can cause trouble and completely disable testing.

test('example', () => {
  externalLibFail()
})

test('example2', () => {
  throw new Error("It will never be called")
})

function externalLibFail() {
  throw "not an Error"
}

@farwayer farwayer changed the title Rejected promise without error will be silently skipped All subsequent tests will be skipped if throw non Error Mar 21, 2023
@pashak09
Copy link

I have opened a PR to fix this issue.

#240

@e-rakovets32
Copy link

When are you going to merge it? I want this fix too. Thanks!

@victordidenko
Copy link

Just encountered this behavior after few years of using uvu, this is very unexpected and very unpleasant :(

I've looked through other issues and found out, that author knew about this behavior since 2021, but did nothing (not even changed documentation) — #130 (comment)

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

No branches or pull requests

4 participants