diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-06-11 08:55:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 08:55:12 -0400 |
commit | 4bc96c5d2ab46ff3ca1af1524c1913c2a5f2745c (patch) | |
tree | 8452947b0267e47c795cadb02d2d1b44b3e40f81 /tests | |
parent | 6a356aff1380e79d67738c5b43aa2b5fee76600d (diff) |
fix(npm): resolve dynamic npm imports individually (#24170)
* https://github.com/denoland/deno_npm/pull/57
* https://github.com/denoland/deno_graph/pull/498
Closes https://github.com/denoland/deno/issues/17802
Diffstat (limited to 'tests')
6 files changed, 38 insertions, 6 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 25fb695b4..62cb84457 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -12868,14 +12868,10 @@ fn lsp_uses_lockfile_for_npm_initialization() { client.initialize_default(); let mut skipping_count = 0; client.wait_until_stderr_line(|line| { - if line.contains("Skipping pending npm resolution.") { + if line.contains("Skipping npm resolution.") { skipping_count += 1; } - assert!( - !line.contains("Running pending npm resolution."), - "Line: {}", - line - ); + assert!(!line.contains("Running npm resolution."), "Line: {}", line); line.contains("Server ready.") }); assert_eq!(skipping_count, 1); diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index 2c074b86f..1d60d9e35 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -1822,6 +1822,7 @@ fn reload_info_not_found_cache_but_exists_remote() { .run(); output.assert_matches_text(concat!( "error: Could not find npm package '@denotest/esm-import-cjs-default' matching '1.0.0'.\n", + " at file:///[WILDCARD]/main.ts:1:8\n", )); output.assert_exit_code(1); diff --git a/tests/registry/npm/@denotest/dep-cannot-parse/1.0.0/package.json b/tests/registry/npm/@denotest/dep-cannot-parse/1.0.0/package.json new file mode 100644 index 000000000..8a069ef72 --- /dev/null +++ b/tests/registry/npm/@denotest/dep-cannot-parse/1.0.0/package.json @@ -0,0 +1,7 @@ +{ + "name": "@denotest/dep-cannot-parse", + "version": "1.0.0", + "dependencies": { + "@denotest/esm-basic": "unknown-scheme:unknown" + } +} diff --git a/tests/specs/npm/dynamic_npm_resolution_failure/__test__.jsonc b/tests/specs/npm/dynamic_npm_resolution_failure/__test__.jsonc new file mode 100644 index 000000000..f816bad86 --- /dev/null +++ b/tests/specs/npm/dynamic_npm_resolution_failure/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run -A main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/dynamic_npm_resolution_failure/main.out b/tests/specs/npm/dynamic_npm_resolution_failure/main.out new file mode 100644 index 000000000..03c733567 --- /dev/null +++ b/tests/specs/npm/dynamic_npm_resolution_failure/main.out @@ -0,0 +1,15 @@ +[UNORDERED_START] +Download http://localhost:4260/chalk +Download http://localhost:4260/@denotest/dep-cannot-parse +[UNORDERED_END] +Download http://localhost:4260/chalk/chalk-5.0.1.tgz +Hi +TypeError: Error in @denotest/dep-cannot-parse@1.0.0 parsing version requirement for dependency: @denotest/esm-basic@unknown-scheme:unknown + +Invalid npm version requirement. Unexpected character. + unknown-scheme:unknown + ~ + at async file:///[WILDLINE]main.ts:5:3 { + code: "ERR_MODULE_NOT_FOUND" +} +Bye diff --git a/tests/specs/npm/dynamic_npm_resolution_failure/main.ts b/tests/specs/npm/dynamic_npm_resolution_failure/main.ts new file mode 100644 index 000000000..0096bca48 --- /dev/null +++ b/tests/specs/npm/dynamic_npm_resolution_failure/main.ts @@ -0,0 +1,9 @@ +import chalk from "npm:chalk"; + +console.log(chalk.green("Hi")); +try { + await import("npm:@denotest/dep-cannot-parse"); +} catch (err) { + console.log(err); +} +console.log(chalk.green("Bye")); |