-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support test coverage reporters in bun test
#3158
Comments
+1 |
Bun v0.7.3 now includes a default code coverage reporter. To use it: bun test --coverage It will output something like: -------------|---------|---------|-------------------
File | % Funcs | % Lines | Uncovered Line #s
-------------|---------|---------|-------------------
All files | 38.89 | 42.11 |
index-0.ts | 33.33 | 36.84 | 10-15,19-24
index-1.ts | 33.33 | 36.84 | 10-15,19-24
index-10.ts | 33.33 | 36.84 | 10-15,19-24
index-2.ts | 33.33 | 36.84 | 10-15,19-24
index-3.ts | 33.33 | 36.84 | 10-15,19-24
index-4.ts | 33.33 | 36.84 | 10-15,19-24
index-5.ts | 33.33 | 36.84 | 10-15,19-24
index-6.ts | 33.33 | 36.84 | 10-15,19-24
index-7.ts | 33.33 | 36.84 | 10-15,19-24
index-8.ts | 33.33 | 36.84 | 10-15,19-24
index-9.ts | 33.33 | 36.84 | 10-15,19-24
index.ts | 100.00 | 100.00 |
-------------|---------|---------|------------------- |
@Jarred-Sumner is there an issue we can follow for support for html, json, etc. reporters for that? |
@ImLunaHey there is an issue for lcov #4015 which could be used to generate an HTML reporter. But feel free to file one for HTML specifically |
(noobie question) Meanwhile we wait for properly report support, I was trying to to consume outup from the cli after running const proc = spawn(["bun", "test"], { stdout: "pipe" });
const output = await new Response(proc.stdout).text(); output it is empty, does anyone know how can I get the coverage output text? ps. I have configured that --coverage it is always enable |
@pukingrainbows try |
ohhh that worked, why was that? shouldn't be part of |
I'm not really sure. I only know because of this comment from Jarred on one of my PRs: #2566 (review). |
What is the problem this feature would solve?
Existing test libraries like Jest and Vitest support coverage reporters like istanbul and c8.
bun test
merely runs the tests, but it does not collect coverage information that could be provided to a reporter.What is the feature you are proposing to solve the problem?
Add the ability to specify a reporter (possibly include a default reporter with Bun) and collect coverage information with a
--coverage
flag or something similar.What alternatives have you considered?
The only alternative is to stick with Jest/Vitest/etc when coverage reporting is needed.
The text was updated successfully, but these errors were encountered: