beforeAll outside of describe increases the number of failed steps by 1
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 681
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Having a `beforeAll` outside any `describe`s leads to the test runner reporting an incorrect number of failed steps: one more than the actual number of tests that have failed.
**Steps to Reproduce**
`deno test` the script below:
```ts
import { assert } from '@std/assert';
import { describe, test, beforeAll } from '@std/testing/bdd';
beforeAll(() => {
// A `beforeAll` outside the `describe`, even empty, increases the number of failed tests by 1
});
describe('the describe', () => {
test('test 1', () => {
assert(Math.random() < 0.0001);
});
test('test 2', () => {
assert(Math.random() === 0.123456);
});
});
```
The output will include `FAILED | 0 passed | 1 failed (3 steps)`.
**Expected behavior**
The final test message should be `FAILED | 0 passed | 1 failed (2 steps)`.
**Environment**
- OS: Ubuntu 24.04
- deno version: 2.7.7
- jsr:@std/expect: 1.0.18
- jsr:@std/testing: 1.0.17
Contributor guide
Research direction
Start by running the provided `deno test` reproduction with `@std/testing/bdd` and confirm that two failed tests produce three steps. Trace the BDD runner's handling of a top-level `beforeAll`; done means the same reproduction reports `FAILED | 0 passed | 1 failed (2 steps)` without changing the behavior of failures inside `describe`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100