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

fix(coverage): add tooltip to line count in html report #23971

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/tools/coverage/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ impl HtmlCoverageReporter {
if *count == 0 {
"<span class='cline-any cline-no'>&nbsp</span>".to_string()
} else {
format!("<span class='cline-any cline-yes'>x{count}</span>")
format!("<span class='cline-any cline-yes' title='This line is covered {count} time{}'>x{count}</span>", if *count > 1 { "s" } else { "" })
}
} else {
"<span class='cline-any cline-neutral'>&nbsp</span>".to_string()
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/coverage_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ fn no_internal_node_code() {

#[test]
fn test_html_reporter() {
// This test case generates a html coverage report of test cases in /tests/testdata/coverage/multisource
// You can get the same reports in ./cov_html by running the following command:
// ```
// ./target/debug/deno test --coverage=cov_html tests/testdata/coverage/multisource
// ./target/debug/deno coverage --html cov_html
// ```
let context = TestContext::default();
let tempdir = context.temp_dir();
let tempdir = tempdir.path().join("cov");
Expand Down Expand Up @@ -481,6 +487,9 @@ fn test_html_reporter() {

let foo_ts_html = tempdir.join("html").join("foo.ts.html").read_to_string();
assert_contains!(foo_ts_html, "<h1>Coverage report for foo.ts</h1>");
// Check that line count has correct title attribute
assert_contains!(foo_ts_html, "<span class='cline-any cline-yes' title='This line is covered 1 time'>x1</span>");
assert_contains!(foo_ts_html, "<span class='cline-any cline-yes' title='This line is covered 3 times'>x3</span>");

let bar_ts_html = tempdir.join("html").join("bar.ts.html").read_to_string();
assert_contains!(bar_ts_html, "<h1>Coverage report for bar.ts</h1>");
Expand Down