summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/mod.rs15
-rw-r--r--cli/tests/integration/run_tests.rs17
-rw-r--r--cli/tests/integration/watcher_tests.rs40
-rw-r--r--cli/tests/testdata/compiler_api_test.ts2
-rw-r--r--cli/tests/testdata/error_027_bundle_with_bare_import.ts.out1
-rw-r--r--cli/tests/testdata/error_type_definitions.ts.out1
-rw-r--r--cli/tests/testdata/jsx/deno-jsx-error.jsonc6
-rw-r--r--cli/tests/testdata/jsx_import_source_error.out2
-rw-r--r--cli/tests/testdata/reference_types_error.js2
-rw-r--r--cli/tests/testdata/reference_types_error.js.out2
10 files changed, 75 insertions, 13 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index 9cd1b2c11..b04f552e8 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -382,13 +382,14 @@ fn ts_reload() {
// check the output of the the bundle program.
let output_path = hello_ts.canonicalize().unwrap();
- assert!(std::str::from_utf8(&output.stderr)
- .unwrap()
- .trim()
- .contains(&format!(
- "host.getSourceFile(\"{}\", Latest)",
- url::Url::from_file_path(&output_path).unwrap().as_str()
- )));
+ assert!(
+ dbg!(std::str::from_utf8(&output.stderr).unwrap().trim()).contains(
+ &format!(
+ "host.getSourceFile(\"{}\", Latest)",
+ url::Url::from_file_path(&output_path).unwrap().as_str()
+ )
+ )
+ );
}
#[test]
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index c04e4731c..d36d0de1b 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1583,6 +1583,23 @@ itest!(worker_close_in_wasm_reactions {
output: "worker_close_in_wasm_reactions.js.out",
});
+itest!(reference_types_error {
+ args: "run reference_types_error.js",
+ output: "reference_types_error.js.out",
+ exit_code: 1,
+});
+
+itest!(reference_types_error_no_check {
+ args: "run --no-check reference_types_error.js",
+ output_str: Some(""),
+});
+
+itest!(jsx_import_source_error {
+ args: "run --config jsx/deno-jsx-error.jsonc jsx_import_source_no_pragma.tsx",
+ output: "jsx_import_source_error.out",
+ exit_code: 1,
+});
+
#[test]
fn no_validate_asm() {
let output = util::deno_cmd()
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);
+}
diff --git a/cli/tests/testdata/compiler_api_test.ts b/cli/tests/testdata/compiler_api_test.ts
index b9755c29a..f51b5647c 100644
--- a/cli/tests/testdata/compiler_api_test.ts
+++ b/cli/tests/testdata/compiler_api_test.ts
@@ -307,7 +307,7 @@ Deno.test({
);
assertEquals(diagnostics.length, 0);
assert(!ignoredOptions);
- assertEquals(stats.length, 12);
+ assertEquals(stats.length, 0);
assertEquals(
Object.keys(files).sort(),
["deno:///bundle.js.map", "deno:///bundle.js"].sort(),
diff --git a/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out b/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out
index 12f38c1c5..e2edd118a 100644
--- a/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out
+++ b/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out
@@ -1 +1,2 @@
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
+ at file:///[WILDCARD]/error_027_bundle_with_bare_import.ts:[WILDCARD]
diff --git a/cli/tests/testdata/error_type_definitions.ts.out b/cli/tests/testdata/error_type_definitions.ts.out
index a0a536f78..5e1d73ca4 100644
--- a/cli/tests/testdata/error_type_definitions.ts.out
+++ b/cli/tests/testdata/error_type_definitions.ts.out
@@ -1 +1,2 @@
[WILDCARD]error: Relative import path "baz" not prefixed with / or ./ or ../
+ at [WILDCARD]/type_definitions/bar.d.ts:[WILDCARD]
diff --git a/cli/tests/testdata/jsx/deno-jsx-error.jsonc b/cli/tests/testdata/jsx/deno-jsx-error.jsonc
new file mode 100644
index 000000000..37cb4dd91
--- /dev/null
+++ b/cli/tests/testdata/jsx/deno-jsx-error.jsonc
@@ -0,0 +1,6 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "jsxImportSource": "./nonexistent"
+ }
+}
diff --git a/cli/tests/testdata/jsx_import_source_error.out b/cli/tests/testdata/jsx_import_source_error.out
new file mode 100644
index 000000000..b9758a99e
--- /dev/null
+++ b/cli/tests/testdata/jsx_import_source_error.out
@@ -0,0 +1,2 @@
+error: Cannot load module "file:///[WILDCARD]/nonexistent/jsx-runtime".
+ at file:///[WILDCARD]/deno-jsx-error.jsonc:1:1
diff --git a/cli/tests/testdata/reference_types_error.js b/cli/tests/testdata/reference_types_error.js
new file mode 100644
index 000000000..68b6c2136
--- /dev/null
+++ b/cli/tests/testdata/reference_types_error.js
@@ -0,0 +1,2 @@
+/// <reference types="./nonexistent.d.ts" />
+export const a = 1;
diff --git a/cli/tests/testdata/reference_types_error.js.out b/cli/tests/testdata/reference_types_error.js.out
new file mode 100644
index 000000000..89b450520
--- /dev/null
+++ b/cli/tests/testdata/reference_types_error.js.out
@@ -0,0 +1,2 @@
+error: Cannot load module "file:///[WILDCARD]/nonexistent.d.ts".
+ at file:///[WILDCARD]/reference_types_error.js:1:23