From bd1358efab8ba7339a8e70034315fa7da840292e Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Mon, 12 Feb 2024 14:35:23 +0100 Subject: fix(console): support NO_COLOR and colors option in all scenarios (#21910) Noticed in #21607 --- tests/integration/run_tests.rs | 14 ++++++++++++++ tests/testdata/run/inspect_color_overwrite.ts | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 tests/testdata/run/inspect_color_overwrite.ts (limited to 'tests') diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 298ce1715..eab7b10ba 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -5140,3 +5140,17 @@ console.log(add(3, 4)); let output = test_context.new_command().args("run main.ts").run(); output.assert_matches_text("[WILDCARD]5\n7\n"); } + +#[test] +fn inspect_color_overwrite() { + let test_context = TestContextBuilder::new().build(); + let output = test_context + .new_command() + .skip_strip_ansi() + .split_output() + .env("NO_COLOR", "1") + .args("run run/inspect_color_overwrite.ts") + .run(); + + assert_eq!(output.stdout(), "foo\u{1b}[31mbar\u{1b}[0m\n"); +} diff --git a/tests/testdata/run/inspect_color_overwrite.ts b/tests/testdata/run/inspect_color_overwrite.ts new file mode 100644 index 000000000..e1e991d87 --- /dev/null +++ b/tests/testdata/run/inspect_color_overwrite.ts @@ -0,0 +1,5 @@ +console.log( + Deno[Deno.internal].inspectArgs(["%cfoo%cbar", "", "color: red"], { + colors: true, + }), +); -- cgit v1.2.3