From 20ae8db50d7d48ad020b83ebe78dc0e9e9eab3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 9 Oct 2024 09:04:44 +0100 Subject: fix(repl): importing json files (#26053) Closes https://github.com/denoland/deno/issues/26041 --- tests/integration/repl_tests.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/integration/repl_tests.rs b/tests/integration/repl_tests.rs index 3f137ce7c..4e00398ce 100644 --- a/tests/integration/repl_tests.rs +++ b/tests/integration/repl_tests.rs @@ -1136,3 +1136,22 @@ fn eval_file_promise_error() { assert_contains!(out, "Uncaught undefined"); assert!(err.is_empty()); } + +#[test] +fn repl_json_imports() { + let context = TestContextBuilder::default().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + temp_dir.write("./data.json", r#"{"hello": "world"}"#); + context + .new_command() + .env("NO_COLOR", "1") + .args_vec(["repl", "-A"]) + .with_pty(|mut console| { + console.write_line_raw( + "import data from './data.json' with { type: 'json' };", + ); + console.expect("undefined"); + console.write_line_raw("data"); + console.expect(r#"{ hello: "world" }"#); + }); +} -- cgit v1.2.3