summaryrefslogtreecommitdiff
path: root/tests/integration/npm_tests.rs
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-07-24 16:37:13 -0700
committerGitHub <noreply@github.com>2024-07-24 23:37:13 +0000
commit795ed23b356dc044cfb497a6189d588604a6c335 (patch)
treeb1e53bac1b69cab4ff0f3da181426bbf024be457 /tests/integration/npm_tests.rs
parent1fad6eb2acc993714fad9d333f409495f5b3d6db (diff)
fix(future): Emit `deno install` warning less often, suggest `deno install` in error message (#24706)
Two small changes: - In our BYONM errors, suggest running `deno install` instead of `npm install` if `DENO_FUTURE` is set - Only emit warning about `deno install` changes if you do `deno install <foo>` with deno_future unset
Diffstat (limited to 'tests/integration/npm_tests.rs')
-rw-r--r--tests/integration/npm_tests.rs132
1 files changed, 0 insertions, 132 deletions
diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs
index e721633a6..6be0298d8 100644
--- a/tests/integration/npm_tests.rs
+++ b/tests/integration/npm_tests.rs
@@ -2454,138 +2454,6 @@ fn byonm_package_specifier_not_installed_and_invalid_subpath() {
}
#[test]
-fn future_byonm_package_specifier_not_installed_and_invalid_subpath() {
- let test_context = TestContextBuilder::for_npm()
- .env("DENO_FUTURE", "1")
- .use_temp_cwd()
- .build();
- let dir = test_context.temp_dir();
- dir.path().join("package.json").write_json(&json!({
- "dependencies": {
- "chalk": "4",
- "@denotest/conditional-exports-strict": "1"
- }
- }));
- dir.write(
- "main.ts",
- "import chalk from 'chalk'; console.log(chalk.green('hi'));",
- );
-
- // no npm install has been run, so this should give an informative error
- let output = test_context.new_command().args("run main.ts").run();
- output.assert_matches_text(
- r#"error: Could not resolve "chalk", but found it in a package.json. Deno expects the node_modules/ directory to be up to date. Did you forget to run `npm install`?
- at file:///[WILDCARD]/main.ts:1:19
-"#,
- );
- output.assert_exit_code(1);
-
- // now test for an invalid sub path after doing an npm install
- dir.write(
- "main.ts",
- "import '@denotest/conditional-exports-strict/test';",
- );
-
- test_context.run_npm("install");
-
- let output = test_context.new_command().args("run main.ts").run();
- output.assert_matches_text(
- r#"error: [ERR_PACKAGE_PATH_NOT_EXPORTED] Package subpath './test' is not defined by "exports" in '[WILDCARD]' imported from '[WILDCARD]main.ts'
- at file:///[WILDCARD]/main.ts:1:8
-"#,
- );
- output.assert_exit_code(1);
-}
-
-#[test]
-fn byonm_package_npm_specifier_not_installed_and_invalid_subpath() {
- let test_context = TestContextBuilder::for_npm()
- .env("DENO_UNSTABLE_BYONM", "1")
- .use_temp_cwd()
- .build();
- let dir = test_context.temp_dir();
- dir.path().join("package.json").write_json(&json!({
- "dependencies": {
- "chalk": "4",
- "@denotest/conditional-exports-strict": "1"
- }
- }));
- dir.write(
- "main.ts",
- "import chalk from 'npm:chalk'; console.log(chalk.green('hi'));",
- );
-
- // no npm install has been run, so this should give an informative error
- let output = test_context.new_command().args("run main.ts").run();
- output.assert_matches_text(
- r#"error: Could not find "chalk" in a node_modules folder. Deno expects the node_modules/ directory to be up to date. Did you forget to run `npm install`?
- at file:///[WILDCARD]/main.ts:1:19
-"#,
- );
- output.assert_exit_code(1);
-
- // now test for an invalid sub path after doing an npm install
- dir.write(
- "main.ts",
- "import 'npm:@denotest/conditional-exports-strict/test';",
- );
-
- test_context.run_npm("install");
-
- let output = test_context.new_command().args("run main.ts").run();
- output.assert_matches_text(
- r#"error: [ERR_PACKAGE_PATH_NOT_EXPORTED] Package subpath './test' is not defined by "exports" in '[WILDLINE]package.json' imported from '[WILDLINE]main.ts'
- at file:///[WILDLINE]/main.ts:1:8
-"#,
- );
- output.assert_exit_code(1);
-}
-
-#[test]
-fn future_byonm_package_npm_specifier_not_installed_and_invalid_subpath() {
- let test_context = TestContextBuilder::for_npm()
- .env("DENO_FUTURE", "1")
- .use_temp_cwd()
- .build();
- let dir = test_context.temp_dir();
- dir.path().join("package.json").write_json(&json!({
- "dependencies": {
- "chalk": "4",
- "@denotest/conditional-exports-strict": "1"
- }
- }));
- dir.write(
- "main.ts",
- "import chalk from 'npm:chalk'; console.log(chalk.green('hi'));",
- );
-
- // no npm install has been run, so this should give an informative error
- let output = test_context.new_command().args("run main.ts").run();
- output.assert_matches_text(
- r#"error: Could not find "chalk" in a node_modules folder. Deno expects the node_modules/ directory to be up to date. Did you forget to run `npm install`?
- at file:///[WILDCARD]/main.ts:1:19
-"#,
- );
- output.assert_exit_code(1);
-
- // now test for an invalid sub path after doing an npm install
- dir.write(
- "main.ts",
- "import 'npm:@denotest/conditional-exports-strict/test';",
- );
-
- test_context.run_npm("install");
-
- let output = test_context.new_command().args("run main.ts").run();
- output.assert_matches_text(
- r#"error: [ERR_PACKAGE_PATH_NOT_EXPORTED] Package subpath './test' is not defined by "exports" in '[WILDLINE]package.json' imported from '[WILDLINE]main.ts'
- at file:///[WILDLINE]/main.ts:1:8
-"#,
- );
- output.assert_exit_code(1);
-}
-
-#[test]
fn byonm_npm_workspaces() {
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
let dir = test_context.temp_dir();