summaryrefslogtreecommitdiff
path: root/tests/integration/watcher_tests.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-08-14 15:21:11 +0200
committerGitHub <noreply@github.com>2024-08-14 15:21:11 +0200
commit130a2592f1e946be563c7f167d7127f49a1014d1 (patch)
treea63627f8e153269b97c70bf4fc0445e6055dd1bd /tests/integration/watcher_tests.rs
parent533d31bc4e9c0cae2b9047850c39c68bf494595e (diff)
fix(cli): support --watch when running cjs npm packages (#25038)
Diffstat (limited to 'tests/integration/watcher_tests.rs')
-rw-r--r--tests/integration/watcher_tests.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs
index 3cec2f442..6203a62d9 100644
--- a/tests/integration/watcher_tests.rs
+++ b/tests/integration/watcher_tests.rs
@@ -3,6 +3,7 @@
use flaky_test::flaky_test;
use test_util as util;
use test_util::assert_contains;
+use test_util::env_vars_for_npm_tests;
use test_util::TempDir;
use tokio::io::AsyncBufReadExt;
use util::DenoChild;
@@ -707,6 +708,42 @@ async fn run_watch_no_dynamic() {
check_alive_then_kill(child);
}
+#[flaky_test(tokio)]
+async fn run_watch_npm_specifier() {
+ let _g = util::http_server();
+ let t = TempDir::new();
+
+ let file_to_watch = t.path().join("file_to_watch.txt");
+ file_to_watch.write("Hello world");
+
+ let mut child = util::deno_cmd()
+ .current_dir(t.path())
+ .envs(env_vars_for_npm_tests())
+ .arg("run")
+ .arg("--watch=file_to_watch.txt")
+ .arg("-L")
+ .arg("debug")
+ .arg("npm:@denotest/bin/cli-cjs")
+ .arg("Hello world")
+ .env("NO_COLOR", "1")
+ .piped_output()
+ .spawn()
+ .unwrap();
+ let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child);
+
+ wait_contains("Hello world", &mut stdout_lines).await;
+ wait_for_watcher("file_to_watch.txt", &mut stderr_lines).await;
+
+ // Change content of the file
+ file_to_watch.write("Hello world2");
+
+ wait_contains("Restarting", &mut stderr_lines).await;
+ wait_contains("Hello world", &mut stdout_lines).await;
+ wait_for_watcher("file_to_watch.txt", &mut stderr_lines).await;
+
+ check_alive_then_kill(child);
+}
+
// TODO(bartlomieju): this test became flaky on macOS runner; it is unclear
// if that's because of a bug in code or the runner itself. We should reenable
// it once we upgrade to XL runners for macOS.