lukeed / lukeed/uvu

Finally block silents errors causing false-positive 0 exit code

Open
#60 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3k
Forks
101
PR merge metrics
No merged PRs in 30d

Description

[the finally block in runner function](https://github.com/lukeed/uvu/blob/0f9dfb7df31d55d063ef7a1e943499f9f89ef97a/src/index.js#L83) silents every error which is thrown outside the inner `try` block.

Example:
```
import { test } from 'uvu'
test.before(() => {
throw Error()
})
test('foo', () => {

})
test.run()
```
although the console output correctly shows that 0 tests passed, the process exits with false-positive exit code 0 and prints no error

besides hooks, also internal errors may cause this, e.g. a [function for error formatting](https://github.com/lukeed/uvu/blob/0f9dfb7df31d55d063ef7a1e943499f9f89ef97a/src/index.js#L48) fails, when a string is passed as an error (`throw 'error string'`)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/index.js at the runner's finally block around line 83, then inspect the error-formatting function around line 48. Reproduce the failing hook and string-thrown-error examples; done means these errors are reported and the process exits with a nonzero code instead of a false-positive 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.