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

Bun test returns exit code 1 even when coverage and coverageThreshold used together #17028

Open
silverbucket opened this issue Feb 3, 2025 · 1 comment
Labels
bug Something isn't working bun:test Something related to the `bun test` runner

Comments

@silverbucket
Copy link

silverbucket commented Feb 3, 2025

What version of Bun is running?

1.2.2+c1708ea6a

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

$ cat bunfig.toml
[test]
coverage = true
coverageThreshold = { functions = 0.85, lines = 0.85 }

$ bun test; echo $?
...
--------------------------------------------------------------------|---------|---------|-------------------
File                                                                | % Funcs | % Lines | Uncovered Line #s
--------------------------------------------------------------------|---------|---------|-------------------
All files                                                           |   87.07 |   90.24 |
...
271 pass
 0 fail
 504 expect() calls
Ran 271 tests across 23 files. [2.41s]
1

What is the expected behavior?

All tests pass, within coverage limits, exit status should be 0.

What do you see instead?

No matter if tests are failing or not, or coverage limits are exceeded or not, the exit status is always 1.

Additional information

You can try this out on my migration branch switch-to-bun:
https://github.com/sockethub/sockethub/tree/switch-to-bun

And view the CI failure here:
https://github.com/sockethub/sockethub/actions/runs/13124596661/job/36618267430?pr=886

@silverbucket silverbucket added bug Something isn't working needs triage labels Feb 3, 2025
@RiskyMH RiskyMH added bun:test Something related to the `bun test` runner and removed needs triage labels Feb 3, 2025
@silverbucket
Copy link
Author

This seems to be happening when using the coverageThreshold and coverage config options together:

$ cat bunfig.toml
[test]
coverage = true
coverageThreshold = { functions = 0.85, lines = 0.85 }

$ bun test; echo $?
...
 271 pass
 0 fail
 504 expect() calls
Ran 271 tests across 23 files. [2.61s]
1

If I remove the coverageThreshold line, tests pass:

$ cat bunfig.toml
[test]
coverage = true

$ bun test; echo $?
 271 pass
 0 fail
 504 expect() calls
Ran 271 tests across 23 files. [2.39s]
0

If I remove the coverage line, tests pass:

$ cat bunfig.toml
[test]
coverageThreshold = { functions = 0.85, lines = 0.85 }

$ bun test; echo $?
 271 pass
 0 fail
 504 expect() calls
Ran 271 tests across 23 files. [2.48s]
0

The coverage amount reported in the output:

--------------------------------------------------------------------|---------|---------|-------------------
File                                                                | % Funcs | % Lines | Uncovered Line #s
--------------------------------------------------------------------|---------|---------|-------------------
All files                                                           |   87.07 |   90.24 |

@silverbucket silverbucket changed the title Bun test returns exit code 1 even when all tests pass Bun test returns exit code 1 even when coverage and coverageThreshold used together Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:test Something related to the `bun test` runner
Projects
None yet
Development

No branches or pull requests

2 participants