summaryrefslogtreecommitdiff
path: root/cli/tests/integration/watcher_tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration/watcher_tests.rs')
-rw-r--r--cli/tests/integration/watcher_tests.rs40
1 files changed, 35 insertions, 5 deletions
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index 02367d780..f0431e301 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -394,7 +394,7 @@ fn bundle_js_watch() {
use std::path::PathBuf;
// Test strategy extends this of test bundle_js by adding watcher
let t = TempDir::new().unwrap();
- let file_to_watch = t.path().join("file_to_watch.js");
+ let file_to_watch = t.path().join("file_to_watch.ts");
write(&file_to_watch, "console.log('Hello world');").unwrap();
assert!(file_to_watch.is_file());
let t = TempDir::new().unwrap();
@@ -418,7 +418,7 @@ fn bundle_js_watch() {
let next_line = stderr_lines.next().unwrap();
assert_contains!(&next_line, CLEAR_SCREEN);
assert_contains!(&next_line, "Bundle started");
- assert_contains!(stderr_lines.next().unwrap(), "file_to_watch.js");
+ assert_contains!(stderr_lines.next().unwrap(), "file_to_watch.ts");
assert_contains!(stderr_lines.next().unwrap(), "mod6.bundle.js");
let file = PathBuf::from(&bundle);
assert!(file.is_file());
@@ -430,7 +430,7 @@ fn bundle_js_watch() {
let next_line = stderr_lines.next().unwrap();
assert_contains!(&next_line, CLEAR_SCREEN);
assert_contains!(&next_line, "File change detected!");
- assert_contains!(stderr_lines.next().unwrap(), "file_to_watch.js");
+ assert_contains!(stderr_lines.next().unwrap(), "file_to_watch.ts");
assert_contains!(stderr_lines.next().unwrap(), "mod6.bundle.js");
let file = PathBuf::from(&bundle);
assert!(file.is_file());
@@ -449,7 +449,7 @@ fn bundle_js_watch() {
#[test]
fn bundle_watch_not_exit() {
let t = TempDir::new().unwrap();
- let file_to_watch = t.path().join("file_to_watch.js");
+ let file_to_watch = t.path().join("file_to_watch.ts");
write(&file_to_watch, "syntax error ^^").unwrap();
let target_file = t.path().join("target.js");
@@ -482,7 +482,7 @@ fn bundle_watch_not_exit() {
let next_line = stderr_lines.next().unwrap();
assert_contains!(&next_line, CLEAR_SCREEN);
assert_contains!(&next_line, "File change detected!");
- assert_contains!(stderr_lines.next().unwrap(), "file_to_watch.js");
+ assert_contains!(stderr_lines.next().unwrap(), "file_to_watch.ts");
assert_contains!(stderr_lines.next().unwrap(), "target.js");
wait_for("Bundle finished", &mut stderr_lines);
@@ -967,3 +967,33 @@ fn test_watch_doc() {
assert_contains!(skip_restarting_line(&mut stderr_lines), "foo.ts$3-6");
check_alive_then_kill(child);
}
+
+#[test]
+fn test_watch_module_graph_error_referrer() {
+ let t = TempDir::new().unwrap();
+ let file_to_watch = t.path().join("file_to_watch.js");
+ write(&file_to_watch, "import './nonexistent.js';").unwrap();
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--watch")
+ .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 line1 = stderr_lines.next().unwrap();
+ assert_contains!(&line1, CLEAR_SCREEN);
+ assert_contains!(&line1, "Process started");
+ let line2 = stderr_lines.next().unwrap();
+ assert_contains!(&line2, "error: Cannot load module");
+ assert_contains!(&line2, "nonexistent.js");
+ let line3 = stderr_lines.next().unwrap();
+ assert_contains!(&line3, " at ");
+ assert_contains!(&line3, "file_to_watch.js");
+ wait_for("Process failed", &mut stderr_lines);
+ check_alive_then_kill(child);
+}