diff --git a/src/bun.js/test/snapshot.zig b/src/bun.js/test/snapshot.zig index 398175a2eb..7562cad792 100644 --- a/src/bun.js/test/snapshot.zig +++ b/src/bun.js/test/snapshot.zig @@ -262,9 +262,17 @@ pub const Snapshots = struct { var last_byte: usize = 0; var last_line: c_ulong = 1; var last_col: c_ulong = 1; + var last_value: []const u8 = ""; for (ils_info.items) |ils| { if (ils.line == last_line and ils.col == last_col) { - try log.addErrorFmt(source, .{ .start = @intCast(uncommitted_segment_end) }, arena, "Failed to update inline snapshot: Multiple inline snapshots for the same call are not supported", .{}); + if (!bun.strings.eql(ils.value, last_value)) { + const DiffFormatter = @import("./diff_format.zig").DiffFormatter; + try log.addErrorFmt(source, .{ .start = @intCast(uncommitted_segment_end) }, arena, "Failed to update inline snapshot: Multiple inline snapshots on the same line must all have the same value:\n{}", .{DiffFormatter{ + .received_string = ils.value, + .expected_string = last_value, + .globalThis = vm.global, + }}); + } continue; } @@ -279,6 +287,7 @@ pub const Snapshots = struct { last_byte += byte_offset_add; last_line = ils.line; last_col = ils.col; + last_value = ils.value; var next_start = last_byte; inline_snapshot_dbg("-> Found byte {}", .{next_start}); diff --git a/test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts b/test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts index c74a2eaaf3..db94caf377 100644 --- a/test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts +++ b/test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts @@ -631,7 +631,9 @@ Date) }); it("should error trying to update the same line twice", () => { tester.testError( - { msg: "error: Failed to update inline snapshot: Multiple inline snapshots for the same call are not supported" }, + { + msg: "error: Failed to update inline snapshot: Multiple inline snapshots on the same line must all have the same value", + }, /*js*/ ` function oops(a) {expect(a).toMatchInlineSnapshot()} test("whoops", () => {