From e0429e2ad641e9207e00838de209ce33b3562f70 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 30 Mar 2023 10:43:16 -0400 Subject: 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 --- cli/tests/integration/repl_tests.rs | 37 +++++++++++++++++++++++++++++++++++++ cli/tests/integration/run_tests.rs | 2 -- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'cli/tests') 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") + }); +} diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 4504c970d..003bc59fc 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -4248,8 +4248,6 @@ itest!(permission_args_quiet { // Regression test for https://github.com/denoland/deno/issues/16772 #[test] -// todo(dsherret): getting a dns error on windows for some reason -#[cfg(unix)] fn file_fetcher_preserves_permissions() { let _guard = util::http_server(); util::with_pty(&["repl", "--quiet"], |mut console| { -- cgit v1.2.3