Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/bun.js/test/jest.zig
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,17 @@ pub fn formatLabel(globalThis: *JSGlobalObject, label: string, function_args: []
const var_path = label[var_start..var_end];
const value = try function_args[0].getIfPropertyExistsFromPath(globalThis, bun.String.init(var_path).toJS(globalThis));
if (!value.isEmptyOrUndefinedOrNull()) {
var formatter = jsc.ConsoleObject.Formatter{ .globalThis = globalThis, .quote_strings = true };
defer formatter.deinit();
bun.handleOom(list.writer().print("{}", .{value.toFmt(&formatter)}));
// For primitive strings, use toString() to avoid adding quotes
// This matches Jest's behavior (https://github.com/jestjs/jest/issues/7689)
if (value.isString()) {
const owned_slice = try value.toSliceOrNull(globalThis);
defer owned_slice.deinit();
bun.handleOom(list.appendSlice(owned_slice.slice()));
} else {
var formatter = jsc.ConsoleObject.Formatter{ .globalThis = globalThis, .quote_strings = true };
defer formatter.deinit();
bun.handleOom(list.writer().print("{}", .{value.toFmt(&formatter)}));
}
idx = var_end;
continue;
}
Expand Down
13 changes: 13 additions & 0 deletions test/regression/issue/23206.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// https://github.com/oven-sh/bun/issues/23206
import { expect, test } from "bun:test";

test.each(["apple", "banana"])("fruit #%# is %s", fruit => {
// Test name should be "fruit #0 is apple" and "fruit #1 is banana"
expect(["apple", "banana"]).toContain(fruit);
});

test.each([{ name: "apple" }, { name: "banana" }])("fruit #%# is $name", fruit => {
// Test name should be "fruit #0 is apple" and "fruit #1 is banana"
// NOT "fruit #0 is "apple"" and "fruit #1 is "banana""
expect(["apple", "banana"]).toContain(fruit.name);
});
Comment thread
pfgithub marked this conversation as resolved.
Outdated