diff options
author | HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> | 2024-10-29 23:55:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-29 22:55:41 +0100 |
commit | 3b28446000d8d063c07ef320314ef493a9e0bffa (patch) | |
tree | f1a9b025955338527e4562c75dfe4d0d4b659fba /tests/integration | |
parent | a69224ea5bd02f08108aac867c492754095f2d34 (diff) |
fix: support watch flag to enable watching other files than the main module on serve subcommand (#26622)
Closes #26618
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/watcher_tests.rs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs index 122353bba..d4705b8d5 100644 --- a/tests/integration/watcher_tests.rs +++ b/tests/integration/watcher_tests.rs @@ -567,6 +567,76 @@ async fn run_watch_no_dynamic() { } #[flaky_test(tokio)] +async fn serve_watch_all() { + let t = TempDir::new(); + let main_file_to_watch = t.path().join("main_file_to_watch.js"); + main_file_to_watch.write( + "export default { + fetch(_request: Request) { + return new Response(\"aaaaaaqqq!\"); + }, + };", + ); + + let mut child = util::deno_cmd() + .current_dir(t.path()) + .arg("serve") + .arg("--watch=another_file.js") + .arg("-L") + .arg("debug") + .arg(&main_file_to_watch) + .env("NO_COLOR", "1") + .piped_output() + .spawn() + .unwrap(); + let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); + + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; + + // Change content of the file + main_file_to_watch.write( + "export default { + fetch(_request: Request) { + return new Response(\"aaaaaaqqq123!\"); + }, + };", + ); + wait_contains("Restarting", &mut stderr_lines).await; + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; + + let another_file = t.path().join("another_file.js"); + another_file.write("export const foo = 0;"); + // Confirm that the added file is watched as well + wait_contains("Restarting", &mut stderr_lines).await; + + main_file_to_watch + .write("import { foo } from './another_file.js'; console.log(foo);"); + wait_contains("Restarting", &mut stderr_lines).await; + wait_contains("0", &mut stdout_lines).await; + + another_file.write("export const foo = 42;"); + wait_contains("Restarting", &mut stderr_lines).await; + wait_contains("42", &mut stdout_lines).await; + + // Confirm that watch continues even with wrong syntax error + another_file.write("syntax error ^^"); + + wait_contains("Restarting", &mut stderr_lines).await; + wait_contains("error:", &mut stderr_lines).await; + + main_file_to_watch.write( + "export default { + fetch(_request: Request) { + return new Response(\"aaaaaaqqq!\"); + }, + };", + ); + wait_contains("Restarting", &mut stderr_lines).await; + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; + check_alive_then_kill(child); +} + +#[flaky_test(tokio)] async fn run_watch_npm_specifier() { let _g = util::http_server(); let t = TempDir::new(); |