Skip to content

Commit f5a7516

Browse files
Document coverage in the guide
1 parent e8f74a2 commit f5a7516

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

guide/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
- [Writing Asynchronous Tests](./wasm-bindgen-test/asynchronous-tests.md)
111111
- [Testing in Headless Browsers](./wasm-bindgen-test/browsers.md)
112112
- [Continuous Integration](./wasm-bindgen-test/continuous-integration.md)
113+
- [Coverage (Experimental)](./wasm-bindgen-test/coverage.md)
113114

114115
- [Contributing to `wasm-bindgen`](./contributing/index.md)
115116
- [Testing](./contributing/testing.md)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generating Coverage Data
2+
3+
You can ask the runner to generate coverage data from functions marked as `#[wasm_bindgen_test]` in the `.profraw` format.
4+
5+
<div class="warning">
6+
Coverage is still in an experimental state and may be unreliable and could experience
7+
breaking changes at any time.
8+
</div>
9+
10+
## Enabling the feature
11+
12+
To enable this feature, you need to enable the `"unstable-coverage"` feature in your `wasm-bindgen-test` dependency.
13+
14+
## Generating the data
15+
16+
### `RUSTFLAGS` that need to be present
17+
18+
Make sure you are using `RUSTFLAGS=-Cinstrument-coverage -Zno-profiler-runtime`.
19+
20+
### Arguments to the test runner
21+
22+
If you are using `wasm-pack` to run the tests, refer to the `wasm-pack` documentation.
23+
24+
Otherwise, you can use the following environment variables when [executing the test runner][1] to control the coverage output:
25+
26+
[1]: usage.html#appendix-using-wasm-bindgen-test-without-wasm-pack
27+
28+
- `WASM_BINDGEN_UNSTABLE_TEST_COVERAGE` to generate a single `.profraw` in your current working directory.
29+
- `WASM_BINDGEN_UNSTABLE_TEST_PROFRAW_OUT` to control the file name of the profraw or the directory in which it is placed
30+
- `WASM_BINDGEN_UNSTABLE_TEST_PROFRAW_PREFIX` to add a custom prefix to the profraw files. This can be useful if you're running the tests automatically in succession.

0 commit comments

Comments
 (0)