summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/repl_tests.rs22
-rw-r--r--cli/tests/testdata/fmt/fmt_check_parse_error.out8
-rw-r--r--cli/tests/testdata/lint/expected_json.out2
-rw-r--r--cli/tests/testdata/run/error_syntax.js.out3
-rw-r--r--cli/tests/testdata/run/error_syntax_empty_trailing_line.mjs.out3
-rw-r--r--cli/tests/testdata/run/swc_syntax_error.ts.out3
-rw-r--r--cli/tests/watcher_tests.rs6
7 files changed, 30 insertions, 17 deletions
diff --git a/cli/tests/repl_tests.rs b/cli/tests/repl_tests.rs
index 418ff00d6..7a13f7553 100644
--- a/cli/tests/repl_tests.rs
+++ b/cli/tests/repl_tests.rs
@@ -52,17 +52,15 @@ mod repl {
#[test]
fn pty_unpaired_braces() {
- util::with_pty(&["repl"], |mut console| {
- console.write_line(")");
- console.write_line("]");
- console.write_line("}");
- console.write_line("close();");
+ for right_brace in &[")", "]", "}"] {
+ util::with_pty(&["repl"], |mut console| {
+ console.write_line(right_brace);
+ console.write_line("close();");
- let output = console.read_all_output();
- assert_contains!(output, "Unexpected token `)`");
- assert_contains!(output, "Unexpected token `]`");
- assert_contains!(output, "Unexpected token `}`");
- });
+ let output = console.read_all_output();
+ assert_contains!(output, "Expression expected");
+ });
+ }
}
#[test]
@@ -518,7 +516,7 @@ mod repl {
None,
false,
);
- assert_contains!(out, "Unexpected token");
+ assert_contains!(out, "Expression expected");
assert!(err.is_empty());
}
}
@@ -565,7 +563,7 @@ mod repl {
Some(vec![("NO_COLOR".to_owned(), "1".to_owned())]),
false,
);
- assert_contains!(out, "Unexpected token `>`");
+ assert_contains!(out, "Expression expected");
assert!(err.is_empty());
}
diff --git a/cli/tests/testdata/fmt/fmt_check_parse_error.out b/cli/tests/testdata/fmt/fmt_check_parse_error.out
index d9b918af7..9854b6c97 100644
--- a/cli/tests/testdata/fmt/fmt_check_parse_error.out
+++ b/cli/tests/testdata/fmt/fmt_check_parse_error.out
@@ -1,6 +1,6 @@
-Error checking: [WILDCARD]
- Line 2, column 7: Expected '{', got '<eof>'
+Error checking: [WILDCARD]parse_error.ts
+ Expected '{', got '<eof>' at [WILDCARD]parse_error.ts:2:7
- class Test
- ~~~~
+ class Test
+ ~~~~
error: Found 1 not formatted file in 1 file
diff --git a/cli/tests/testdata/lint/expected_json.out b/cli/tests/testdata/lint/expected_json.out
index 61680607c..08ea0d3e0 100644
--- a/cli/tests/testdata/lint/expected_json.out
+++ b/cli/tests/testdata/lint/expected_json.out
@@ -58,7 +58,7 @@
"errors": [
{
"file_path": "[WILDCARD]malformed.js",
- "message": "Expected '{', got 'B' at [WILDCARD]malformed.js:4:16"
+ "message": "Expected '{', got 'B' at [WILDCARD]malformed.js:4:16\n\n export class A B C\n ~"
}
]
}
diff --git a/cli/tests/testdata/run/error_syntax.js.out b/cli/tests/testdata/run/error_syntax.js.out
index 6d3f05b8e..fa4d51686 100644
--- a/cli/tests/testdata/run/error_syntax.js.out
+++ b/cli/tests/testdata/run/error_syntax.js.out
@@ -1 +1,4 @@
error: The module's source code could not be parsed: Expected ',', got 'following' at [WILDCARD]/error_syntax.js:3:6
+
+ (the following is a syntax error ^^ ! )
+ ~~~~~~~~~
diff --git a/cli/tests/testdata/run/error_syntax_empty_trailing_line.mjs.out b/cli/tests/testdata/run/error_syntax_empty_trailing_line.mjs.out
index f4bbc6708..2eb290bb5 100644
--- a/cli/tests/testdata/run/error_syntax_empty_trailing_line.mjs.out
+++ b/cli/tests/testdata/run/error_syntax_empty_trailing_line.mjs.out
@@ -1 +1,4 @@
error: The module's source code could not be parsed: Unexpected eof at [WILDCARD]/error_syntax_empty_trailing_line.mjs:2:22
+
+ setTimeout(() => {}),
+ ~
diff --git a/cli/tests/testdata/run/swc_syntax_error.ts.out b/cli/tests/testdata/run/swc_syntax_error.ts.out
index c968db5e9..81b0c1949 100644
--- a/cli/tests/testdata/run/swc_syntax_error.ts.out
+++ b/cli/tests/testdata/run/swc_syntax_error.ts.out
@@ -1 +1,4 @@
error: The module's source code could not be parsed: Unexpected token `}`. Expected an identifier, void, yield, null, await, break, a string literal, a numeric literal, true, false, `, -, import, this, typeof, {, [, ( at [WILDCARD]syntax_error.ts:4:1
+
+ }
+ ~
diff --git a/cli/tests/watcher_tests.rs b/cli/tests/watcher_tests.rs
index b5c4fe5c0..0b9749e48 100644
--- a/cli/tests/watcher_tests.rs
+++ b/cli/tests/watcher_tests.rs
@@ -470,6 +470,9 @@ mod watcher {
let next_line = stderr_lines.next().unwrap();
assert_contains!(&next_line, "Bundle started");
assert_contains!(stderr_lines.next().unwrap(), "error:");
+ assert_eq!(stderr_lines.next().unwrap(), "");
+ assert_eq!(stderr_lines.next().unwrap(), " syntax error ^^");
+ assert_eq!(stderr_lines.next().unwrap(), " ~~~~~");
assert_contains!(stderr_lines.next().unwrap(), "Bundle failed");
// the target file hasn't been created yet
assert!(!target_file.is_file());
@@ -929,6 +932,9 @@ mod watcher {
write(&another_test, "syntax error ^^").unwrap();
assert_contains!(stderr_lines.next().unwrap(), "Restarting");
assert_contains!(stderr_lines.next().unwrap(), "error:");
+ assert_eq!(stderr_lines.next().unwrap(), "");
+ assert_eq!(stderr_lines.next().unwrap(), " syntax error ^^");
+ assert_eq!(stderr_lines.next().unwrap(), " ~~~~~");
assert_contains!(stderr_lines.next().unwrap(), "Test failed");
// Then restore the file