summaryrefslogtreecommitdiff
path: root/cli/tests/integration/repl_tests.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-30 10:43:16 -0400
committerGitHub <noreply@github.com>2023-03-30 10:43:16 -0400
commite0429e2ad641e9207e00838de209ce33b3562f70 (patch)
tree496c38dadb79c4dc9ae4eea755e2ac6a65440ad4 /cli/tests/integration/repl_tests.rs
parent3deade4b14de809f67ed0471f8e91c91b25fedcc (diff)
fix(repl): improve package.json support (#18497)
1. Fixes a cosmetic issue in the repl where it would display lsp warning messages. 2. Lazily loads dependencies from the package.json on use. 3. Supports using bare specifiers from package.json in the REPL. Closes #17929 Closes #18494
Diffstat (limited to 'cli/tests/integration/repl_tests.rs')
-rw-r--r--cli/tests/integration/repl_tests.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs
index 95a747523..27a9b716c 100644
--- a/cli/tests/integration/repl_tests.rs
+++ b/cli/tests/integration/repl_tests.rs
@@ -5,6 +5,7 @@ use test_util::assert_contains;
use test_util::assert_ends_with;
use test_util::assert_not_contains;
use util::TempDir;
+use util::TestContextBuilder;
#[test]
fn pty_multiline() {
@@ -884,3 +885,39 @@ fn pty_tab_indexable_props() {
assert_not_contains!(output, "0", "1", "2");
});
}
+
+#[test]
+fn package_json_uncached_no_error() {
+ let test_context = TestContextBuilder::for_npm()
+ .use_temp_cwd()
+ .use_http_server()
+ .env("RUST_BACKTRACE", "1")
+ .build();
+ let temp_dir = test_context.temp_dir();
+ temp_dir.write(
+ "package.json",
+ r#"{
+ "dependencies": {
+ "@denotest/esm-basic": "1.0.0"
+ }
+}
+"#,
+ );
+ test_context.new_command().with_pty(|mut console| {
+ console.write_line("console.log(123 + 456);");
+ console.expect("579");
+ assert_not_contains!(
+ console.all_output(),
+ "Could not set npm package requirements",
+ );
+
+ // should support getting the package now though
+ console
+ .write_line("import { getValue, setValue } from '@denotest/esm-basic';");
+ console.expect("undefined");
+ console.write_line("setValue(12 + 30);");
+ console.expect("undefined");
+ console.write_line("getValue()");
+ console.expect("42")
+ });
+}