mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
### What does this PR do?
Before:
```js
❯ bun test /Users/jarred/Code/bun/test/cli/test/test-filter-lifecycle.js -t "should run test"
bun test v1.2.20-canary.135 (1ac2391b)
test/cli/test/test-filter-lifecycle.js:
# Unhandled error between tests
-------------------------------
1 | // This test is intended to be able to run in Vitest and Jest.
2 | describe("top-level sibling", () => {
3 | beforeAll(() => {
4 | throw new Error("FAIL");
^
error: FAIL
at <anonymous> (test-filter-lifecycle.js:4:27)
at test-filter-lifecycle.js:2:1
at loadAndEvaluateModule (2:1)
-------------------------------
✗ top-level sibling > test
<parent beforeAll>
<beforeAll>
# Unhandled error between tests
-------------------------------
65 | beforeEach(() => {
66 | throw new Error("FAIL");
67 | });
68 |
69 | afterEach(() => {
70 | throw new Error("FAIL");
^
error: FAIL
at <anonymous> (test-filter-lifecycle.js:70:29)
-------------------------------
<afterEach>
<parent afterEach>
<parent beforeEach>
<beforeEach>
<test 1>
✓ parent > should run > test [0.02ms]
<afterEach>
<parent afterEach>
<parent beforeEach>
<beforeEach>
<test 2>
✓ parent > should run > test 2 [0.02ms]
# Unhandled error between tests
-------------------------------
106 | console.log("<beforeEach>");
107 | });
108 |
109 | afterEach(() => {
110 | if (++ran.afterEach > 2) {
111 | throw new Error("FAIL 2");
^
error: FAIL 2
at <anonymous> (test-filter-lifecycle.js:111:33)
-------------------------------
# Unhandled error between tests
-------------------------------
106 | console.log("<beforeEach>");
107 | });
108 |
109 | afterEach(() => {
110 | if (++ran.afterEach > 2) {
111 | throw new Error("FAIL 2");
^
error: FAIL 2
at <anonymous> (test-filter-lifecycle.js:111:33)
-------------------------------
<afterAll>
<parent afterAll>
2 pass
3 filtered out
1 fail
4 errors
Ran 3 tests across 1 file. [93.00ms]
```
After:
```js
bun test <version> (<revision>)
<parent beforeAll>
<beforeAll>
<parent beforeEach>
<beforeEach>
<test 1>
<afterEach>
<parent afterEach>
<parent beforeEach>
<beforeEach>
<test 2>
<afterEach>
<parent afterEach>
<afterAll>
<parent afterAll>
test/cli/test/test-filter-lifecycle.js:
(pass) parent > should run > test
(pass) parent > should run > test 2
2 pass
4 filtered out
0 fail
Ran 2 tests across 1 file.
```
### How did you verify your code works?
There is a test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>