diff --git a/crates/oxc_formatter/src/write/call_arguments.rs b/crates/oxc_formatter/src/write/call_arguments.rs index a9727a74fd67a..80c6aabfeb75d 100644 --- a/crates/oxc_formatter/src/write/call_arguments.rs +++ b/crates/oxc_formatter/src/write/call_arguments.rs @@ -69,7 +69,17 @@ impl<'a> Format<'a> for AstNode<'a, ArenaVec<'a, Argument<'a>>> { if is_simple_module_import || call_expression.is_some_and(|call| { - is_commonjs_or_amd_call(self, call, f) || is_test_call_expression(call) + is_commonjs_or_amd_call(self, call, f) + || ((self.len() != 2 + || matches!( + arguments.first(), + Some( + Argument::StringLiteral(_) + | Argument::TemplateLiteral(_) + | Argument::TaggedTemplateExpression(_) + ) + )) + && is_test_call_expression(call)) }) || is_multiline_template_only_args(self, f.source_text()) || is_react_hook_with_deps_array(self, f.comments()) diff --git a/crates/oxc_formatter/tests/fixtures/js/calls/test.js b/crates/oxc_formatter/tests/fixtures/js/calls/test.js index 9291a006d0296..287e44828a1b6 100644 --- a/crates/oxc_formatter/tests/fixtures/js/calls/test.js +++ b/crates/oxc_formatter/tests/fixtures/js/calls/test.js @@ -20,4 +20,6 @@ test.describe.only("Describe only", () => {}); // These simpler patterns should still work test.only("Test only", () => {}); describe.only("Describe only", () => {}); -it.only("It only", () => {}); \ No newline at end of file +it.only("It only", () => {}); + +test(code.replace((c) => ""), () => {}); \ No newline at end of file diff --git a/crates/oxc_formatter/tests/fixtures/js/calls/test.js.snap b/crates/oxc_formatter/tests/fixtures/js/calls/test.js.snap index 29795f125c55b..d1e39e96f9c86 100644 --- a/crates/oxc_formatter/tests/fixtures/js/calls/test.js.snap +++ b/crates/oxc_formatter/tests/fixtures/js/calls/test.js.snap @@ -25,6 +25,8 @@ test.describe.only("Describe only", () => {}); test.only("Test only", () => {}); describe.only("Describe only", () => {}); it.only("It only", () => {}); + +test(code.replace((c) => ""), () => {}); ==================== Output ==================== // Test patterns with multiple levels should not break incorrectly test.describe.serial("My test suite", () => { @@ -50,4 +52,9 @@ test.only("Test only", () => {}); describe.only("Describe only", () => {}); it.only("It only", () => {}); +test( + code.replace((c) => ""), + () => {}, +); + ===================== End =====================