summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/watcher_tests.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index 89d4bf3f7..cdc7a2c98 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -997,3 +997,51 @@ fn test_watch_module_graph_error_referrer() {
wait_for("Process failed", &mut stderr_lines);
check_alive_then_kill(child);
}
+
+#[test]
+fn watch_with_no_clear_screen_flag() {
+ let t = TempDir::new().unwrap();
+ let file_to_watch = t.path().join("file_to_watch.js");
+ write(&file_to_watch, "export const foo = 0;").unwrap();
+
+ // choose deno run subcommand to test --no-clear-screen flag
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--watch")
+ .arg("--no-clear-screen")
+ .arg("--unstable")
+ .arg(&file_to_watch)
+ .env("NO_COLOR", "1")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let (_, mut stderr_lines) = child_lines(&mut child);
+
+ let next_line = stderr_lines.next().unwrap();
+
+ // no clear screen
+ assert!(!&next_line.contains(CLEAR_SCREEN));
+ assert_contains!(&next_line, "Process started");
+ assert_contains!(
+ stderr_lines.next().unwrap(),
+ "Process finished. Restarting on file change..."
+ );
+
+ // Change content of the file
+ write(&file_to_watch, "export const bar = 0;").unwrap();
+
+ let next_line = stderr_lines.next().unwrap();
+
+ // no clear screen
+ assert!(!&next_line.contains(CLEAR_SCREEN));
+
+ assert_contains!(&next_line, "Watcher File change detected! Restarting!");
+ assert_contains!(
+ stderr_lines.next().unwrap(),
+ "Process finished. Restarting on file change..."
+ );
+
+ check_alive_then_kill(child);
+}