summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/coverage_tests.rs54
-rw-r--r--cli/tests/testdata/coverage/no_tests_included/expected.out1
-rw-r--r--cli/tests/testdata/coverage/no_tests_included/foo.test.js6
-rw-r--r--cli/tests/testdata/coverage/no_tests_included/foo.test.mts6
-rw-r--r--cli/tests/testdata/coverage/no_tests_included/foo.test.ts6
-rw-r--r--cli/tests/testdata/coverage/no_tests_included/foo.ts3
6 files changed, 76 insertions, 0 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs
index 440d6b17e..79e15d95b 100644
--- a/cli/tests/integration/coverage_tests.rs
+++ b/cli/tests/integration/coverage_tests.rs
@@ -27,6 +27,13 @@ fn no_snaps() {
}
#[test]
+fn no_tests() {
+ no_tests_included("foo", "mts");
+ no_tests_included("foo", "ts");
+ no_tests_included("foo", "js");
+}
+
+#[test]
fn error_if_invalid_cache() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let deno_dir = context.deno_dir();
@@ -277,6 +284,53 @@ fn no_snaps_included(test_name: &str, extension: &str) {
output.assert_exit_code(0);
}
+fn no_tests_included(test_name: &str, extension: &str) {
+ let context = TestContext::default();
+ let tempdir = context.deno_dir();
+ let tempdir = tempdir.path().join("cov");
+
+ let output = context
+ .new_command()
+ .args_vec(vec![
+ "test".to_string(),
+ "--quiet".to_string(),
+ "--allow-read".to_string(),
+ format!("--coverage={}", tempdir.to_str().unwrap()),
+ format!("coverage/no_tests_included/{test_name}.test.{extension}"),
+ ])
+ .run();
+
+ output.assert_exit_code(0);
+ output.skip_output_check();
+
+ let output = context
+ .new_command()
+ .args_vec(vec![
+ "coverage".to_string(),
+ format!("{}/", tempdir.to_str().unwrap()),
+ ])
+ .split_output()
+ .run();
+
+ // Verify there's no "Check" being printed
+ assert!(output.stderr().is_empty());
+
+ let actual = util::strip_ansi_codes(output.stdout()).to_string();
+
+ let expected = fs::read_to_string(
+ util::testdata_path().join("coverage/no_tests_included/expected.out"),
+ )
+ .unwrap();
+
+ if !util::wildcard_match(&expected, &actual) {
+ println!("OUTPUT\n{actual}\nOUTPUT");
+ println!("EXPECTED\n{expected}\nEXPECTED");
+ panic!("pattern match failed");
+ }
+
+ output.assert_exit_code(0);
+}
+
#[test]
fn no_npm_cache_coverage() {
let context = TestContext::default();
diff --git a/cli/tests/testdata/coverage/no_tests_included/expected.out b/cli/tests/testdata/coverage/no_tests_included/expected.out
new file mode 100644
index 000000000..3b2469f2d
--- /dev/null
+++ b/cli/tests/testdata/coverage/no_tests_included/expected.out
@@ -0,0 +1 @@
+cover [WILDCARD]/no_tests_included/foo.ts ... 100.000% (3/3)
diff --git a/cli/tests/testdata/coverage/no_tests_included/foo.test.js b/cli/tests/testdata/coverage/no_tests_included/foo.test.js
new file mode 100644
index 000000000..06b13d743
--- /dev/null
+++ b/cli/tests/testdata/coverage/no_tests_included/foo.test.js
@@ -0,0 +1,6 @@
+import { addNumbers } from "./foo.ts";
+import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts";
+
+Deno.test("addNumbers works", () => {
+ assertEquals(addNumbers(1, 2), 3);
+});
diff --git a/cli/tests/testdata/coverage/no_tests_included/foo.test.mts b/cli/tests/testdata/coverage/no_tests_included/foo.test.mts
new file mode 100644
index 000000000..44aa73872
--- /dev/null
+++ b/cli/tests/testdata/coverage/no_tests_included/foo.test.mts
@@ -0,0 +1,6 @@
+import { addNumbers } from './foo.ts';
+import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts";
+
+Deno.test("addNumbers works", () => {
+ assertEquals(addNumbers(1, 2), 3);
+});
diff --git a/cli/tests/testdata/coverage/no_tests_included/foo.test.ts b/cli/tests/testdata/coverage/no_tests_included/foo.test.ts
new file mode 100644
index 000000000..06b13d743
--- /dev/null
+++ b/cli/tests/testdata/coverage/no_tests_included/foo.test.ts
@@ -0,0 +1,6 @@
+import { addNumbers } from "./foo.ts";
+import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts";
+
+Deno.test("addNumbers works", () => {
+ assertEquals(addNumbers(1, 2), 3);
+});
diff --git a/cli/tests/testdata/coverage/no_tests_included/foo.ts b/cli/tests/testdata/coverage/no_tests_included/foo.ts
new file mode 100644
index 000000000..fc2860ef0
--- /dev/null
+++ b/cli/tests/testdata/coverage/no_tests_included/foo.ts
@@ -0,0 +1,3 @@
+export function addNumbers(a: number, b: number): number {
+ return a + b;
+}