summaryrefslogtreecommitdiff
path: root/cli/tests/integration_tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r--cli/tests/integration_tests.rs69
1 files changed, 67 insertions, 2 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index f892b9a87..653f5a008 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -413,6 +413,71 @@ fn js_unit_tests() {
}
#[test]
+fn ts_dependency_recompilation() {
+ let t = TempDir::new().expect("tempdir fail");
+ let ats = t.path().join("a.ts");
+
+ std::fs::write(
+ &ats,
+ "
+ import { foo } from \"./b.ts\";
+
+ function print(str: string): void {
+ console.log(str);
+ }
+
+ print(foo);",
+ )
+ .unwrap();
+
+ let bts = t.path().join("b.ts");
+ std::fs::write(
+ &bts,
+ "
+ export const foo = \"foo\";",
+ )
+ .unwrap();
+
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg(&ats)
+ .output()
+ .expect("failed to spawn script");
+
+ let stdout_output = std::str::from_utf8(&output.stdout).unwrap().trim();
+ let stderr_output = std::str::from_utf8(&output.stderr).unwrap().trim();
+
+ assert!(stdout_output.ends_with("foo"));
+ assert!(stderr_output.starts_with("Compile"));
+
+ // Overwrite contents of b.ts and run again
+ std::fs::write(
+ &bts,
+ "
+ export const foo = 5;",
+ )
+ .expect("error writing file");
+
+ let output = util::deno_cmd()
+ .current_dir(util::root_path())
+ .env("NO_COLOR", "1")
+ .arg("run")
+ .arg(&ats)
+ .output()
+ .expect("failed to spawn script");
+
+ let stdout_output = std::str::from_utf8(&output.stdout).unwrap().trim();
+ let stderr_output = std::str::from_utf8(&output.stderr).unwrap().trim();
+
+ // error: TS2345 [ERROR]: Argument of type '5' is not assignable to parameter of type 'string'.
+ assert!(stderr_output.contains("TS2345"));
+ assert!(!output.status.success());
+ assert!(stdout_output.is_empty());
+}
+
+#[test]
fn bundle_exports() {
// First we have to generate a bundle of some module that has exports.
let mod1 = util::root_path().join("cli/tests/subdir/mod1.ts");
@@ -1377,7 +1442,7 @@ itest!(error_004_missing_module {
});
itest!(error_005_missing_dynamic_import {
- args: "run --reload --allow-read error_005_missing_dynamic_import.ts",
+ args: "run --reload --allow-read --quiet error_005_missing_dynamic_import.ts",
exit_code: 1,
output: "error_005_missing_dynamic_import.ts.out",
});
@@ -1424,7 +1489,7 @@ itest!(error_014_catch_dynamic_import_error {
});
itest!(error_015_dynamic_import_permissions {
- args: "run --reload error_015_dynamic_import_permissions.js",
+ args: "run --reload --quiet error_015_dynamic_import_permissions.js",
output: "error_015_dynamic_import_permissions.out",
exit_code: 1,
http_server: true,