lukeed / lukeed/uvu

Errors are not reporeted when thrown from `before` contexts

Open
#191 3 comments 14 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

## Current Behavior

When using test suites, and a `before` throws an error, the only indication of the error being thrown is that the number of tests passed is 0 when there is 1 test in total.

## Expected Behavior

The error being thrown should be bubbled up and reported as any other error would be

## Minimum Reproduction

```js
const { suite } = require("uvu");
const { ok } = require("uvu/assert");

const TestSuite = suite(
"This suite will not report an error from the before context, just that no tests were ran"
);
TestSuite.before(() => {
throw new Error("You will never see this");
});
TestSuite("I should be reported on!", () => {
ok(true);
});
TestSuite.run();
```

[You can find a reproduction of the error here](https://github.com/jmcdo29/uvu-context-error)

## Reproduction steps

```sh
git clone
cd uvu-context-error
pnpm i / npm i / yarn
node index
```

## Other Information

I get the same outcome whether using `uvu` as a CLI (like the `test` script does) or calling the file directly

```
❯ node index.js
This suite will not report an error from the before context, just that no tests were ran (0 / 1)

Total: 1
Passed: 0
Skipped: 0
Duration: 1.06ms
```

```
❯ pnpm test

> uvu-before-fail@0.0.0 test ~/uvu-before-fail
> uvu . index\.js

index.js
This suite will not report an error from the before context, just that no tests were ran (0 / 1)

Total: 1
Passed: 0
Skipped: 0
Duration: 0.88ms
```

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 with the provided index.js reproduction and run node index.js, then compare it with the pnpm test command. Trace how TestSuite.before handles the thrown error and how the suite reports its result. Done means the thrown Error is visibly reported instead of only showing 0 passed tests.

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.