@jeroenzwart/istanbun 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeroen Zwart
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,125 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <img src=".github/logo.svg" width="160" alt="istanbun logo">
3
+ <h1 style="margin: 0; padding: 0">istanbun</h1>
4
+ </div>
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ Istanbul coverage reporters for `bun test`.
7
+
8
+ `bun test --coverage` can only print a text table or write an lcov file. istanbun runs
9
+ `bun test` for you, converts Bun's lcov output into an Istanbul coverage map and renders it
10
+ with any [istanbul-reports](https://github.com/istanbuljs/istanbuljs/tree/main/packages/istanbul-reports/lib)
11
+ reporter: `html`, `text-summary`, `cobertura`, `clover`, `json`, `teamcity` and more.
12
+
13
+ istanbun is to Bun what [c8](https://github.com/bcoe/c8) is to Node: it does not instrument
14
+ your code. Bun's native coverage feeds the Istanbul reporting stack.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ bun add -d @jeroenzwart/istanbun
20
+ ```
21
+
22
+ The package installs an `istanbun` command. Without installing, run it with
23
+ `bunx @jeroenzwart/istanbun`.
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ bunx istanbun # bun test --coverage, Istanbul text table
29
+ bunx istanbun --reporter html --reporter text-summary
30
+ bunx istanbun --reporter cobertura --output-dir reports/coverage
31
+ bunx istanbun -- test/unit --bail # everything after -- goes to bun test
32
+ bunx istanbun --lcov coverage/lcov.info --reporter json # convert an existing lcov file
33
+ bunx istanbun --watch --reporter html # re-render after every bun test rerun
34
+ ```
35
+
36
+ | Flag | Default | Meaning |
37
+ | -------------------------------- | ---------- | ------------------------------------------------------- |
38
+ | `--reporter <name>` (repeatable) | `text` | Any istanbul-reports reporter name |
39
+ | `--output-dir <path>` | `coverage` | Directory for file-based reporters |
40
+ | `--lcov <path>` | – | Use this lcov file instead of running `bun test` |
41
+ | `--watch` | off | Run `bun test --watch` and regenerate after every rerun |
42
+ | `--help` | | Print usage |
43
+ | `--` | | Pass the remaining arguments to `bun test` |
44
+
45
+ The exit code is the exit code of `bun test`, so a failing suite still fails your CI. With
46
+ `--lcov` the exit code is `0`. Invalid options, an unknown reporter or a `bunfig.toml` that
47
+ cannot produce lcov output exit with `2` before any test runs. When a run loads no source
48
+ file at all, Bun writes no coverage; istanbun then prints a notice, writes no reports and still
49
+ returns the exit code of `bun test`.
50
+
51
+ Reporter names: `clover`, `cobertura`, `html`, `html-spa`, `json`, `json-summary`, `lcov`,
52
+ `lcovonly`, `teamcity`, `text`, `text-lcov`, `text-summary`.
53
+
54
+ ## Configuration
55
+
56
+ istanbun reads `bunfig.toml` from the working directory. Defaults for the CLI flags live in
57
+ an `[istanbun]` table; Bun ignores tables it does not know.
58
+
59
+ ```toml
60
+ [test]
61
+ coverageReporter = ["text", "lcov"] # Bun's own setting, see "Known limitations"
62
+ coverageDir = "coverage" # Bun's own setting
63
+
64
+ [istanbun]
65
+ reporters = ["html", "text-summary"]
66
+ outputDir = "coverage"
67
+ ```
68
+
69
+ Precedence for reporters and the output directory: CLI flag, then `[istanbun]`, then
70
+ `[test].coverageDir` (output directory only), then the built-in defaults.
71
+
72
+ The `lcov` and `lcovonly` reporters write their own `lcov.info` into the output directory.
73
+ When that is Bun's `coverageDir`, Istanbul's file replaces the one Bun wrote; the coverage
74
+ data is the same, only the formatting differs.
75
+
76
+ Everything else in `[test]` (`coverageThreshold`, `coveragePathIgnorePatterns`,
77
+ `coverageSkipTestFiles`, `coverageIgnoreSourcemaps`, `root`, `preload`) is applied by Bun
78
+ itself before istanbun sees the lcov file, so it works without any istanbun configuration.
79
+
80
+ ## Known limitations
81
+
82
+ **No function names or branches.** Bun's lcov contains per-line hit counts and function
83
+ totals only. JavaScriptCore reports neither branches nor function names, as Bun's own
84
+ cobertura reporter PR puts it ([oven-sh/bun#40218](https://github.com/oven-sh/bun/pull/40218);
85
+ see also [oven-sh/bun#7100](https://github.com/oven-sh/bun/issues/7100)). Reports therefore
86
+ show statements and lines, while functions and branches read `100% (0/0)`. istanbun already
87
+ parses `FN`, `FNDA` and `BRDA` records, so richer output from a future Bun is picked up
88
+ automatically.
89
+
90
+ **bunfig overrides the CLI.** Bun's documentation says command-line flags override
91
+ `bunfig.toml`, but for coverage the opposite holds (measured on Bun 1.4.2):
92
+ `[test].coverageReporter` and `[test].coverageDir` win over `--coverage-reporter` and
93
+ `--coverage-dir`. istanbun detects this. When your bunfig sets `coverageReporter` without
94
+ `"lcov"`, istanbun stops with a clear message instead of running tests that cannot produce
95
+ an lcov file. When `coverageDir` is set, istanbun reads the lcov file from there.
96
+
97
+ ## Programmatic API
98
+
99
+ ```typescript
100
+ import { Istanbun } from '@jeroenzwart/istanbun'
101
+
102
+ const result = await Istanbun.create({
103
+ reporters: ['html', 'text-summary'],
104
+ outputDirectory: 'coverage',
105
+ bunTestArguments: ['test/unit'],
106
+ onReport: coverageMap => console.log(coverageMap.getCoverageSummary().lines.pct),
107
+ }).run()
108
+
109
+ result.exitCode // exit code of bun test
110
+ result.coverageMap // istanbul-lib-coverage CoverageMap
111
+ ```
112
+
113
+ Options: `reporters`, `outputDirectory`, `bunTestArguments`, `lcovPath`, `watch`,
114
+ `workingDirectory` and `onReport`. Unset options fall back to `bunfig.toml` as described
115
+ above. In watch mode `run()` resolves when `bun test` exits and `onReport` is called after
116
+ every rerun. Configuration errors throw an `IstanbunError` with a `code` such as
117
+ `UNKNOWN_REPORTER` or `LCOV_REPORTER_NOT_CONFIGURED` and an optional `hint`.
118
+
119
+ ## Development
120
+
121
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for setup, scripts, project structure and tests.
122
+
123
+ ## License
124
+
125
+ MIT