diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 62bfe422294c..0900c90ecda3 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -396,9 +396,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; } diff --git a/src/cli/Arguments.zig b/src/cli/Arguments.zig index 1d4bea63b869..c5719586196b 100644 --- a/src/cli/Arguments.zig +++ b/src/cli/Arguments.zig @@ -404,6 +404,7 @@ pub fn parse(allocator: std.mem.Allocator, ctx: Command.Context, comptime cmd: C if (timeout_ms.len > 0) { ctx.test_options.default_timeout_ms = std.fmt.parseInt(u32, timeout_ms, 10) catch { Output.prettyErrorln("error: Invalid timeout: \"{s}\"", .{timeout_ms}); + Output.flush(); Global.exit(1); }; } @@ -468,11 +469,13 @@ pub fn parse(allocator: std.mem.Allocator, ctx: Command.Context, comptime cmd: C if (bail.len > 0) { ctx.test_options.bail = std.fmt.parseInt(u32, bail, 10) catch |e| { Output.prettyErrorln("error: --bail expects a number: {s}", .{@errorName(e)}); + Output.flush(); Global.exit(1); }; if (ctx.test_options.bail == 0) { Output.prettyErrorln("error: --bail expects a number greater than 0", .{}); + Output.flush(); Global.exit(1); } } else { diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 28c11d2bba1f..7d3bf10cbcae 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -929,6 +929,7 @@ pub const CommandLineReporter = struct { if (this.summary().fail == this.jest.bail) { this.printSummary(); Output.prettyError("\nBailed out after {d} failure{s}\n", .{ this.jest.bail, if (this.jest.bail == 1) "" else "s" }); + Output.flush(); Global.exit(1); } }, diff --git a/test/cli/test/bun-test.test.ts b/test/cli/test/bun-test.test.ts index c462bdfaf487..4724d1052bd8 100644 --- a/test/cli/test/bun-test.test.ts +++ b/test/cli/test/bun-test.test.ts @@ -951,8 +951,8 @@ describe("bun test", () => { `, }); - expect(stderr).toContain('"fs" module > has $method'); - expect(stderr).toContain('"path" module > has $method'); + expect(stderr).toContain("fs module > has $method"); + expect(stderr).toContain("path module > has $method"); expect(stderr).toContain("2 pass"); }); @@ -976,8 +976,8 @@ describe("bun test", () => { `, }); - expect(stderr).toContain('(pass) user "john_doe" age 30 active true'); - expect(stderr).toContain('(pass) user "jane_smith" age 25 active false'); + expect(stderr).toContain("(pass) user john_doe age 30 active true"); + expect(stderr).toContain("(pass) user jane_smith age 25 active false"); expect(stderr).toContain("2 pass"); }); @@ -1027,8 +1027,8 @@ describe("bun test", () => { `, }); - expect(stderr).toContain('(pass) "Alice" from "NYC"'); - expect(stderr).toContain('(pass) "Bob" from "LA"'); + expect(stderr).toContain("(pass) Alice from NYC"); + expect(stderr).toContain("(pass) Bob from LA"); expect(stderr).toContain("2 pass"); }); @@ -1056,8 +1056,8 @@ describe("bun test", () => { `, }); - expect(stderr).toContain('(pass) first user is "Alice"'); - expect(stderr).toContain('(pass) first user is "Carol"'); + expect(stderr).toContain("(pass) first user is Alice"); + expect(stderr).toContain("(pass) first user is Carol"); expect(stderr).toContain("2 pass"); }); @@ -1085,9 +1085,9 @@ describe("bun test", () => { `, }); - expect(stderr).toContain('"underscore"'); - expect(stderr).toContain('"dollar"'); - expect(stderr).toContain('"mix"'); + expect(stderr).toContain("underscore"); + expect(stderr).toContain("dollar"); + expect(stderr).toContain("mix"); expect(stderr).toContain("$123invalid"); expect(stderr).toContain("$hasdash"); expect(stderr).toContain("$hasspace"); @@ -1118,7 +1118,7 @@ describe("bun test", () => { `, }); - expect(stderr).toContain('First user: "Alice" with tag: "admin"'); + expect(stderr).toContain("First user: Alice with tag: admin"); }); test("handles missing properties gracefully", () => { @@ -1460,7 +1460,7 @@ function runTest({ const { stderr, exitCode } = spawnSync({ cwd, cmd: [bunExe(), "test", ...args], - env: { ...bunEnv, ...env }, + env: { ...bunEnv, AGENT: "0", ...env }, stderr: "pipe", stdout: "ignore", });