diff options
Diffstat (limited to 'cli/tests')
4 files changed, 57 insertions, 0 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs index 022f216d8..440d6b17e 100644 --- a/cli/tests/integration/coverage_tests.rs +++ b/cli/tests/integration/coverage_tests.rs @@ -278,6 +278,54 @@ fn no_snaps_included(test_name: &str, extension: &str) { } #[test] +fn no_npm_cache_coverage() { + 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_npm_coverage/no_npm_coverage_test.ts"), + ]) + .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_npm_coverage/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_transpiled_lines() { let context = TestContext::default(); let tempdir = context.deno_dir(); diff --git a/cli/tests/testdata/coverage/no_npm_coverage/expected.out b/cli/tests/testdata/coverage/no_npm_coverage/expected.out new file mode 100644 index 000000000..ca4511277 --- /dev/null +++ b/cli/tests/testdata/coverage/no_npm_coverage/expected.out @@ -0,0 +1 @@ +cover [WILDCARD]/no_npm_coverage/no_npm_coverage.ts ... 100.000% (4/4) diff --git a/cli/tests/testdata/coverage/no_npm_coverage/no_npm_coverage.ts b/cli/tests/testdata/coverage/no_npm_coverage/no_npm_coverage.ts new file mode 100644 index 000000000..4233b2e5d --- /dev/null +++ b/cli/tests/testdata/coverage/no_npm_coverage/no_npm_coverage.ts @@ -0,0 +1,4 @@ +import chalk from "npm:chalk"; +export function main() { + console.log(chalk.red("RED")); +} diff --git a/cli/tests/testdata/coverage/no_npm_coverage/no_npm_coverage_test.ts b/cli/tests/testdata/coverage/no_npm_coverage/no_npm_coverage_test.ts new file mode 100644 index 000000000..8305f9597 --- /dev/null +++ b/cli/tests/testdata/coverage/no_npm_coverage/no_npm_coverage_test.ts @@ -0,0 +1,4 @@ +import { main } from "./no_npm_coverage.ts"; +Deno.test("main", () => { + main(); +}); |