summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2023-12-12 12:42:57 +0900
committerGitHub <noreply@github.com>2023-12-12 12:42:57 +0900
commit5ddf8732f089c93667a667155cd923250d723758 (patch)
tree4fc307e939c341d88e8013a0d8aed48360816fed /cli/tests
parenta4f45f709278208cb61501df2792412f11aed3c4 (diff)
feat(coverage): add summary reporter (#21535)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/coverage_tests.rs61
-rw-r--r--cli/tests/testdata/coverage/multisource/baz/quux.ts9
-rw-r--r--cli/tests/testdata/coverage/multisource/foo.ts7
-rw-r--r--cli/tests/testdata/coverage/multisource/test.ts2
4 files changed, 75 insertions, 4 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs
index d3affd4de..4d927a16d 100644
--- a/cli/tests/integration/coverage_tests.rs
+++ b/cli/tests/integration/coverage_tests.rs
@@ -115,7 +115,11 @@ fn run_coverage_text(test_name: &str, extension: &str) {
let output = context
.new_command()
- .args_vec(vec!["coverage".to_string(), format!("{}/", tempdir)])
+ .args_vec(vec![
+ "coverage".to_string(),
+ "--pretty".to_string(),
+ format!("{}/", tempdir),
+ ])
.split_output()
.run();
@@ -184,7 +188,11 @@ fn multifile_coverage() {
let output = context
.new_command()
- .args_vec(vec!["coverage".to_string(), format!("{}/", tempdir)])
+ .args_vec(vec![
+ "coverage".to_string(),
+ "--pretty".to_string(),
+ format!("{}/", tempdir),
+ ])
.split_output()
.run();
@@ -255,6 +263,7 @@ fn no_snaps_included(test_name: &str, extension: &str) {
.args_vec(vec![
"coverage".to_string(),
"--include=no_snaps_included.ts".to_string(),
+ "--pretty".to_string(),
format!("{}/", tempdir),
])
.split_output()
@@ -303,6 +312,7 @@ fn no_tests_included(test_name: &str, extension: &str) {
.args_vec(vec![
"coverage".to_string(),
format!("--exclude={}", util::std_path().canonicalize()),
+ "--pretty".to_string(),
format!("{}/", tempdir),
])
.split_output()
@@ -350,7 +360,11 @@ fn no_npm_cache_coverage() {
let output = context
.new_command()
- .args_vec(vec!["coverage".to_string(), format!("{}/", tempdir)])
+ .args_vec(vec![
+ "coverage".to_string(),
+ "--pretty".to_string(),
+ format!("{}/", tempdir),
+ ])
.split_output()
.run();
@@ -397,6 +411,7 @@ fn no_transpiled_lines() {
.args_vec(vec![
"coverage".to_string(),
"--include=no_transpiled_lines/index.ts".to_string(),
+ "--pretty".to_string(),
format!("{}/", tempdir),
])
.run();
@@ -575,3 +590,43 @@ fn test_html_reporter() {
.unwrap();
assert!(baz_quux_ts_html.contains("<h1>Coverage report for baz/quux.ts</h1>"));
}
+
+#[test]
+fn test_summary_reporter() {
+ let context = TestContext::default();
+ let tempdir = context.temp_dir();
+ let tempdir = tempdir.path().join("cov");
+
+ let output = context
+ .new_command()
+ .args_vec(vec![
+ "test".to_string(),
+ "--quiet".to_string(),
+ format!("--coverage={}", tempdir),
+ "coverage/multisource".to_string(),
+ ])
+ .run();
+
+ output.assert_exit_code(0);
+ output.skip_output_check();
+
+ let output = context
+ .new_command()
+ .args_vec(vec!["coverage".to_string(), format!("{}/", tempdir)])
+ .run();
+
+ output.assert_exit_code(0);
+ output.assert_matches_text(
+ "----------------------------------
+File | Branch % | Line % |
+----------------------------------
+ bar.ts | 0.0 | 57.1 |
+ baz/quux.ts | 0.0 | 28.6 |
+ baz/qux.ts | 100.0 | 100.0 |
+ foo.ts | 50.0 | 76.9 |
+----------------------------------
+ All files | 40.0 | 61.0 |
+----------------------------------
+",
+ );
+}
diff --git a/cli/tests/testdata/coverage/multisource/baz/quux.ts b/cli/tests/testdata/coverage/multisource/baz/quux.ts
index ab8c62db6..6032f6f3c 100644
--- a/cli/tests/testdata/coverage/multisource/baz/quux.ts
+++ b/cli/tests/testdata/coverage/multisource/baz/quux.ts
@@ -1,6 +1,13 @@
export function quux(cond: boolean) {
if (cond) {
- return 1;
+ const a = 1;
+ const b = a;
+ const c = b;
+ const d = c;
+ const e = d;
+ const f = e;
+ const g = f;
+ return g;
} else {
return 2;
}
diff --git a/cli/tests/testdata/coverage/multisource/foo.ts b/cli/tests/testdata/coverage/multisource/foo.ts
index 023f82556..0559cadd8 100644
--- a/cli/tests/testdata/coverage/multisource/foo.ts
+++ b/cli/tests/testdata/coverage/multisource/foo.ts
@@ -1,5 +1,12 @@
export function foo(cond: boolean) {
+ let a = 0;
if (cond) {
+ a = 1;
+ } else {
+ a = 2;
+ }
+
+ if (a == 4) {
return 1;
} else {
return 2;
diff --git a/cli/tests/testdata/coverage/multisource/test.ts b/cli/tests/testdata/coverage/multisource/test.ts
index 6adf6f52c..350421177 100644
--- a/cli/tests/testdata/coverage/multisource/test.ts
+++ b/cli/tests/testdata/coverage/multisource/test.ts
@@ -5,6 +5,7 @@ import { quux } from "./baz/quux.ts";
Deno.test("foo", () => {
foo(true);
+ foo(false);
});
Deno.test("bar", () => {
@@ -13,6 +14,7 @@ Deno.test("bar", () => {
Deno.test("qux", () => {
qux(true);
+ qux(false);
});
Deno.test("quux", () => {