From 01bc2f530ea311a231f19b8f620b6cc9f94f0886 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Wed, 6 Mar 2024 13:24:15 +0000 Subject: feat(unstable/pm): support npm packages in 'deno add' (#22715) --- tests/integration/pm_tests.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/integration/pm_tests.rs b/tests/integration/pm_tests.rs index cc5527c40..668519bdc 100644 --- a/tests/integration/pm_tests.rs +++ b/tests/integration/pm_tests.rs @@ -2,9 +2,7 @@ use deno_core::serde_json::json; use test_util::assert_contains; -use test_util::env_vars_for_jsr_tests; -// use test_util::env_vars_for_npm_tests; -// use test_util::itest; +use test_util::env_vars_for_jsr_npm_tests; use test_util::TestContextBuilder; #[test] @@ -110,21 +108,24 @@ fn add_multiple() { } #[test] -fn add_not_supported_npm() { +fn add_npm() { let context = pm_context_builder().build(); + let temp_dir = context.temp_dir().path(); - let output = context - .new_command() - .args("add @denotest/add npm:express") - .run(); - output.assert_exit_code(1); + let output = context.new_command().args("add npm:chalk@4.1").run(); + output.assert_exit_code(0); let output = output.combined_output(); - assert_contains!(output, "error: Adding npm: packages is currently not supported. Package: npm:express"); + assert_contains!(output, "Add chalk"); + temp_dir.join("deno.json").assert_matches_json(json!({ + "imports": { + "chalk": "npm:chalk@^4.1.2" + } + })); } fn pm_context_builder() -> TestContextBuilder { TestContextBuilder::new() .use_http_server() - .envs(env_vars_for_jsr_tests()) + .envs(env_vars_for_jsr_npm_tests()) .use_temp_cwd() } -- cgit v1.2.3