Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
ad4b9db729 fix: preserve snapshot order when using -u flag with filters or .only
Previously, when using the -u flag to update snapshots, the snapshot
file would be truncated and rewritten from scratch. This caused two issues:

1. When using test filters or .only, snapshots for tests that didn't run
   would be deleted from the snapshot file
2. The order of snapshots in the file was not preserved

This commit changes the behavior to:
- Read the existing snapshot file instead of truncating it
- Track which snapshots are accessed during the test run
- Merge the updates with the original file, preserving:
  - Snapshots that weren't touched (from filtered-out tests)
  - The original order of snapshots in the file
  - Updates to changed snapshots
  - New snapshots (appended at the end)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 02:49:46 +00:00
3 changed files with 580 additions and 528 deletions

View File

@@ -3,19 +3,10 @@ pub const Snapshots = struct {
const snapshots_dir_name = "__snapshots__" ++ [_]u8{std.fs.path.sep};
pub const ValuesHashMap = std.HashMap(usize, string, bun.IdentityContext(usize), std.hash_map.default_max_load_percentage);
allocator: std.mem.Allocator,
update_snapshots: bool,
total: usize = 0,
added: usize = 0,
passed: usize = 0,
failed: usize = 0,
file_buf: *std.ArrayList(u8),
values: *ValuesHashMap,
counts: *bun.StringHashMap(usize),
_current_file: ?File = null,
snapshot_dir_path: ?string = null,
inline_snapshots_to_write: *std.AutoArrayHashMap(TestRunner.File.ID, std.ArrayList(InlineSnapshotToWrite)),
pub const SnapshotUpdate = struct {
name: []const u8, // owned
value: ?[]const u8, // owned, null means keep existing
};
pub const InlineSnapshotToWrite = struct {
line: c_ulong,
@@ -40,6 +31,23 @@ pub const Snapshots = struct {
file: std.fs.File,
};
allocator: std.mem.Allocator,
update_snapshots: bool,
total: usize = 0,
added: usize = 0,
passed: usize = 0,
failed: usize = 0,
file_buf: *std.ArrayList(u8),
values: *ValuesHashMap,
counts: *bun.StringHashMap(usize),
_current_file: ?File = null,
snapshot_dir_path: ?string = null,
inline_snapshots_to_write: *std.AutoArrayHashMap(TestRunner.File.ID, std.ArrayList(InlineSnapshotToWrite)),
// Track snapshot updates when update_snapshots is true
snapshot_updates: *std.AutoHashMap(usize, SnapshotUpdate),
pub fn addCount(this: *Snapshots, expect: *Expect, hint: []const u8) !struct { []const u8, usize } {
this.total += 1;
const snapshot_name = try expect.getSnapshotName(this.allocator, hint);
@@ -80,6 +88,19 @@ pub const Snapshots = struct {
const name_hash = bun.hash(name_with_counter);
if (this.values.get(name_hash)) |expected| {
// Snapshot exists. If update_snapshots is true, track that we matched it
if (this.update_snapshots) {
// Check if value changed
const new_value = if (!strings.eqlLong(target_value, expected, true))
try this.allocator.dupe(u8, target_value)
else
null;
try this.snapshot_updates.put(name_hash, .{
.name = try this.allocator.dupe(u8, name_with_counter),
.value = new_value,
});
}
return expected;
}
@@ -93,6 +114,14 @@ pub const Snapshots = struct {
}
}
// Track new snapshot when update_snapshots is true
if (this.update_snapshots) {
try this.snapshot_updates.put(name_hash, .{
.name = try this.allocator.dupe(u8, name_with_counter),
.value = try this.allocator.dupe(u8, target_value),
});
}
const estimated_length = "\nexports[`".len + name_with_counter.len + "`] = `".len + target_value.len + "`;\n".len;
try this.file_buf.ensureUnusedCapacity(estimated_length + 10);
try this.file_buf.writer().print(
@@ -182,12 +211,206 @@ pub const Snapshots = struct {
}
}
pub fn writeSnapshotFile(this: *Snapshots) !void {
if (this._current_file) |_file| {
var file = _file;
fn mergeSnapshotUpdates(this: *Snapshots, file: File) !void {
// Parse the original file to understand its structure
const vm = VirtualMachine.get();
const opts = js_parser.Parser.Options.init(vm.transpiler.options.jsx, .js);
var temp_log = logger.Log.init(this.allocator);
const test_file = Jest.runner.?.files.get(file.id);
const test_filename = test_file.source.path.name.filename;
const dir_path = test_file.source.path.name.dirWithTrailingSlash();
var snapshot_file_path_buf: bun.PathBuffer = undefined;
var remain: []u8 = snapshot_file_path_buf[0..bun.MAX_PATH_BYTES];
bun.copy(u8, remain, dir_path);
remain = remain[dir_path.len..];
bun.copy(u8, remain, snapshots_dir_name);
remain = remain[snapshots_dir_name.len..];
bun.copy(u8, remain, test_filename);
remain = remain[test_filename.len..];
bun.copy(u8, remain, ".snap");
remain = remain[".snap".len..];
remain[0] = 0;
const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0];
const source = &logger.Source.initPathString(snapshot_file_path, this.file_buf.items);
var parser = try js_parser.Parser.init(
opts,
&temp_log,
source,
vm.transpiler.options.define,
this.allocator,
);
const parse_result = try parser.parse();
var ast = if (parse_result == .ast) parse_result.ast else {
// If parsing fails, just write what we have
file.file.writeAll(this.file_buf.items) catch {
return error.FailedToWriteSnapshotFile;
};
return;
};
defer ast.deinit();
// Build the new file content
var result = std.ArrayList(u8).init(this.allocator);
defer result.deinit();
try result.appendSlice(file_header);
if (ast.exports_ref.isNull()) {
// No exports, just write new snapshots
for (this.file_buf.items[file_header.len..]) |byte| {
try result.append(byte);
}
} else {
const exports_ref = ast.exports_ref;
// Process each statement, updating or keeping as needed
for (ast.parts.slice()) |part| {
for (part.stmts) |stmt| {
switch (stmt.data) {
.s_expr => |expr| {
if (expr.value.data == .e_binary and expr.value.data.e_binary.op == .bin_assign) {
const left = expr.value.data.e_binary.left;
if (left.data == .e_index and left.data.e_index.index.data == .e_string and left.data.e_index.target.data == .e_identifier) {
const target: js_ast.E.Identifier = left.data.e_index.target.data.e_identifier;
var index: *js_ast.E.String = left.data.e_index.index.data.e_string;
if (target.ref.eql(exports_ref) and expr.value.data.e_binary.right.data == .e_string) {
const key = index.slice(this.allocator);
defer if (!index.isUTF8()) this.allocator.free(key);
const name_hash = bun.hash(key);
if (this.snapshot_updates.get(name_hash)) |update| {
// This snapshot was touched during the test run
if (update.value) |new_value| {
// Value was updated, write new value
try result.writer().print(
"\nexports[`{}`] = `{}`;\n",
.{
strings.formatEscapes(key, .{ .quote_char = '`' }),
strings.formatEscapes(new_value, .{ .quote_char = '`' }),
},
);
} else {
// Value was accessed but unchanged, keep original
var value_string = expr.value.data.e_binary.right.data.e_string;
const value = value_string.slice(this.allocator);
defer if (!value_string.isUTF8()) this.allocator.free(value);
try result.writer().print(
"\nexports[`{}`] = `{}`;\n",
.{
strings.formatEscapes(key, .{ .quote_char = '`' }),
strings.formatEscapes(value, .{ .quote_char = '`' }),
},
);
}
} else {
// This snapshot was not touched, preserve it
var value_string = expr.value.data.e_binary.right.data.e_string;
const value = value_string.slice(this.allocator);
defer if (!value_string.isUTF8()) this.allocator.free(value);
try result.writer().print(
"\nexports[`{}`] = `{}`;\n",
.{
strings.formatEscapes(key, .{ .quote_char = '`' }),
strings.formatEscapes(value, .{ .quote_char = '`' }),
},
);
}
}
}
}
},
else => {},
}
}
}
// Add any new snapshots that weren't in the original file
var update_itr = this.snapshot_updates.iterator();
while (update_itr.next()) |entry| {
const name_hash = entry.key_ptr.*;
const update = entry.value_ptr.*;
// Check if this hash was already in the original file
var found_in_original = false;
for (ast.parts.slice()) |part| {
for (part.stmts) |stmt| {
switch (stmt.data) {
.s_expr => |expr| {
if (expr.value.data == .e_binary and expr.value.data.e_binary.op == .bin_assign) {
const left = expr.value.data.e_binary.left;
if (left.data == .e_index and left.data.e_index.index.data == .e_string and left.data.e_index.target.data == .e_identifier) {
const target: js_ast.E.Identifier = left.data.e_index.target.data.e_identifier;
var index: *js_ast.E.String = left.data.e_index.index.data.e_string;
if (target.ref.eql(exports_ref)) {
const key = index.slice(this.allocator);
defer if (!index.isUTF8()) this.allocator.free(key);
if (bun.hash(key) == name_hash) {
found_in_original = true;
break;
}
}
}
}
},
else => {},
}
}
if (found_in_original) break;
}
// If this is a new snapshot, add it
if (!found_in_original) {
if (update.value) |new_value| {
try result.writer().print(
"\nexports[`{}`] = `{}`;\n",
.{
strings.formatEscapes(update.name, .{ .quote_char = '`' }),
strings.formatEscapes(new_value, .{ .quote_char = '`' }),
},
);
}
}
}
}
// Write the result to the file
file.file.seekTo(0) catch {
return error.FailedToWriteSnapshotFile;
};
file.file.writeAll(result.items) catch {
return error.FailedToWriteSnapshotFile;
};
if (result.items.len < this.file_buf.items.len) {
file.file.setEndPos(result.items.len) catch {
return error.FailedToWriteSnapshotFile;
};
}
}
pub fn writeSnapshotFile(this: *Snapshots) !void {
if (this._current_file) |_file| {
var file = _file;
if (this.update_snapshots and this.snapshot_updates.count() > 0) {
// When updating snapshots, merge changes instead of replacing the whole file
try this.mergeSnapshotUpdates(file);
} else {
// Normal write path (no updates or not in update mode)
file.file.seekTo(0) catch {
return error.FailedToWriteSnapshotFile;
};
file.file.writeAll(this.file_buf.items) catch {
return error.FailedToWriteSnapshotFile;
};
file.file.setEndPos(this.file_buf.items.len) catch {
return error.FailedToWriteSnapshotFile;
};
}
file.file.close();
this.file_buf.clearAndFree();
@@ -202,6 +425,16 @@ pub const Snapshots = struct {
this.allocator.free(key.*);
}
this.counts.clearAndFree();
// Clear snapshot updates
var update_itr = this.snapshot_updates.valueIterator();
while (update_itr.next()) |update| {
this.allocator.free(update.name);
if (update.value) |value| {
this.allocator.free(value);
}
}
this.snapshot_updates.clearAndFree();
}
}
@@ -512,8 +745,8 @@ pub const Snapshots = struct {
remain[0] = 0;
const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0];
var flags: i32 = bun.O.CREAT | bun.O.RDWR;
if (this.update_snapshots) flags |= bun.O.TRUNC;
// Don't truncate - we need to read existing snapshots for comparison
const flags: i32 = bun.O.CREAT | bun.O.RDWR;
const fd = switch (bun.sys.open(snapshot_file_path, flags, 0o644)) {
.result => |_fd| _fd,
.err => |err| return .initErr(err),
@@ -525,21 +758,18 @@ pub const Snapshots = struct {
};
errdefer file.file.close();
if (this.update_snapshots) {
// Read the existing file to load snapshots for comparison
const length = try file.file.getEndPos();
if (length == 0) {
try this.file_buf.appendSlice(file_header);
} else {
const length = try file.file.getEndPos();
if (length == 0) {
try this.file_buf.appendSlice(file_header);
} else {
const buf = try this.allocator.alloc(u8, length);
_ = try file.file.preadAll(buf, 0);
if (comptime bun.Environment.isWindows) {
try file.file.seekTo(0);
}
try this.file_buf.appendSlice(buf);
this.allocator.free(buf);
const buf = try this.allocator.alloc(u8, length);
_ = try file.file.preadAll(buf, 0);
if (comptime bun.Environment.isWindows) {
try file.file.seekTo(0);
}
try this.file_buf.appendSlice(buf);
this.allocator.free(buf);
}
try this.parseFile(file);

View File

@@ -1320,6 +1320,7 @@ pub const TestCommand = struct {
var snapshot_values = Snapshots.ValuesHashMap.init(ctx.allocator);
var snapshot_counts = bun.StringHashMap(usize).init(ctx.allocator);
var inline_snapshots_to_write = std.AutoArrayHashMap(TestRunner.File.ID, std.ArrayList(Snapshots.InlineSnapshotToWrite)).init(ctx.allocator);
var snapshot_updates = std.AutoHashMap(usize, Snapshots.SnapshotUpdate).init(ctx.allocator);
jsc.VirtualMachine.isBunTest = true;
var reporter = try ctx.allocator.create(CommandLineReporter);
@@ -1347,6 +1348,7 @@ pub const TestCommand = struct {
.values = &snapshot_values,
.counts = &snapshot_counts,
.inline_snapshots_to_write = &inline_snapshots_to_write,
.snapshot_updates = &snapshot_updates,
},
.bun_test_root = .init(ctx.allocator),
},

View File

@@ -1,4 +1,18 @@
// Jest Snapshot v1, https://bun.sh/docs/test/snapshots
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[`most types: Function 1`] = `[Function: test1000000]`;
exports[`most types: null 1`] = `null`;
exports[`most types: arrow function 1`] = `[Function]`;
exports[`most types: testing 7 1`] = `7`;
exports[`most types: testing 4 1`] = `6`;
exports[`most types: testing 5 1`] = `5`;
exports[`most types: testing 4 2`] = `4`;
exports[`most types 1`] = `3`;
@@ -6,6 +20,305 @@ exports[`most types 2`] = `1`;
exports[`most types 3`] = `2`;
exports[`most types: testing 7 2`] = `9`;
exports[`most types: testing 7 3`] = `8`;
exports[`most types: undefined 1`] = `undefined`;
exports[`most types: string 1`] = `"hello string"`;
exports[`most types: Array with empty array 1`] = `
[
[],
]
`;
exports[`most types: Array with multiple empty arrays 1`] = `
[
[],
[],
[],
[],
]
`;
exports[`most types: Array with nested arrays 1`] = `
[
1,
2,
[
3,
4,
],
[
4,
[
5,
6,
],
],
8,
]
`;
exports[`most types: Buffer with property 1`] = `
{
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
}
`;
exports[`most types: Buffer2 1`] = `
{
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
}
`;
exports[`most types: Buffer3 1`] = `
{
"data": [
104,
101,
108,
96,
10,
10,
96,
],
"type": "Buffer",
}
`;
exports[`most types: Object with Buffer 1`] = `
{
"a": {
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
},
}
`;
exports[`most types: nested object with Buffer 1`] = `
{
"a": {
"b": {
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
},
},
}
`;
exports[`most types: nested object with empty Buffer 1`] = `
{
"a": {
"b": {
"data": [],
"type": "Buffer",
},
},
}
`;
exports[`most types: Object with empty Buffer 1`] = `
{
"a": {
"data": [],
"type": "Buffer",
},
}
`;
exports[`most types: Buffer 1`] = `
{
"data": [],
"type": "Buffer",
}
`;
exports[`most types: Date 1`] = `1970-01-01T00:00:00.000Z`;
exports[`most types: Error 1`] = `[Error: hello]`;
exports[`most types: Empty Error 1`] = `[Error]`;
exports[`most types: empty map 1`] = `Map {}`;
exports[`most types: Map 1`] = `
Map {
1 => "eight",
"seven" => "312390840812",
}
`;
exports[`most types: Set 1`] = `Set {}`;
exports[`most types: Set2 1`] = `
Set {
1,
2,
3,
4,
5,
6,
7,
8,
9,
}
`;
exports[`most types: WeakMap 1`] = `WeakMap {}`;
exports[`most types: WeakSet 1`] = `WeakSet {}`;
exports[`most types: Promise 1`] = `Promise {}`;
exports[`most types: RegExp 1`] = `/hello/`;
exports[`most types: String with property 1`] = `String {}`;
exports[`most types: Object with String with property 1`] = `
{
"a": String {},
}
`;
exports[`most types: Object with empty String 1`] = `
{
"a": String {},
}
`;
exports[`most types: String 1`] = `
String {
"0": "h",
"1": "e",
"2": "l",
"3": "l",
"4": "o",
}
`;
exports[`most types: Number 1`] = `Number {}`;
exports[`most types: Object with empty object 1`] = `
{
"a": {},
}
`;
exports[`most types: Boolean 1`] = `Boolean {}`;
exports[`most types: Int8Array with one element 1`] = `
Int8Array [
3,
]
`;
exports[`most types: Int8Array with elements 1`] = `
Int8Array [
1,
2,
3,
4,
]
`;
exports[`most types: Int8Array 1`] = `Int8Array []`;
exports[`most types: Object with Int8Array 1`] = `
{
"a": 1,
"b": Int8Array [
123,
-89,
4,
34,
],
}
`;
exports[`most types: nested object with empty Int8Array 1`] = `
{
"a": {
"b": Int8Array [],
},
}
`;
exports[`most types: Uint8Array 1`] = `Uint8Array []`;
exports[`most types: Uint8ClampedArray 1`] = `Uint8ClampedArray []`;
exports[`most types: Int16Array 1`] = `Int16Array []`;
exports[`most types: Uint16Array 1`] = `Uint16Array []`;
exports[`most types: Int32Array 1`] = `Int32Array []`;
exports[`most types: Uint32Array 1`] = `Uint32Array []`;
exports[`most types: Float32Array 1`] = `Float32Array []`;
exports[`most types: Float64Array 1`] = `Float64Array []`;
exports[`most types: ArrayBuffer 1`] = `ArrayBuffer []`;
exports[`most types: DataView 1`] = `DataView []`;
exports[`most types: Object 1`] = `{}`;
exports[`most types: Object2 1`] = `
{
"a": 1,
"b": 2,
}
`;
exports[`most types: Array 1`] = `[]`;
exports[`most types: Array2 1`] = `
[
1,
2,
3,
]
`;
exports[`most types: Class 1`] = `
A {
"a": 1,
"b": 2,
"c": 3,
}
`;
exports[`most types 4`] = `
{
"a": 1,
@@ -56,435 +369,14 @@ exports[`most types 5`] = `
}
`;
exports[`most types: Array 1`] = `[]`;
exports[`most types: Array with empty array 1`] = `
[
[],
]
`;
exports[`most types: Array with multiple empty arrays 1`] = `
[
[],
[],
[],
[],
]
`;
exports[`most types: Array with nested arrays 1`] = `
[
1,
2,
[
3,
4,
],
[
4,
[
5,
6,
],
],
8,
]
`;
exports[`most types: Array2 1`] = `
[
1,
2,
3,
]
`;
exports[`most types: ArrayBuffer 1`] = `ArrayBuffer []`;
exports[`most types: Boolean 1`] = `Boolean {}`;
exports[`most types: Buffer 1`] = `
{
"data": [],
"type": "Buffer",
}
`;
exports[`most types: Buffer with property 1`] = `
{
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
}
`;
exports[`most types: Buffer2 1`] = `
{
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
}
`;
exports[`most types: Buffer3 1`] = `
{
"data": [
104,
101,
108,
96,
10,
10,
96,
],
"type": "Buffer",
}
`;
exports[`most types: Class 1`] = `
A {
"a": 1,
"b": 2,
"c": 3,
}
`;
exports[`most types: DataView 1`] = `DataView []`;
exports[`most types: Date 1`] = `1970-01-01T00:00:00.000Z`;
exports[`most types: Empty Error 1`] = `[Error]`;
exports[`most types: Error 1`] = `[Error: hello]`;
exports[`most types: Float32Array 1`] = `Float32Array []`;
exports[`most types: Float64Array 1`] = `Float64Array []`;
exports[`most types: Function 1`] = `[Function: test1000000]`;
exports[`most types: Int8Array 1`] = `Int8Array []`;
exports[`most types: Int8Array with elements 1`] = `
Int8Array [
1,
2,
3,
4,
]
`;
exports[`most types: Int8Array with one element 1`] = `
Int8Array [
3,
]
`;
exports[`most types: Int16Array 1`] = `Int16Array []`;
exports[`most types: Int32Array 1`] = `Int32Array []`;
exports[`most types: Map 1`] = `
Map {
1 => "eight",
"seven" => "312390840812",
}
`;
exports[`most types: Number 1`] = `Number {}`;
exports[`most types: Object 1`] = `{}`;
exports[`most types: Object with Buffer 1`] = `
{
"a": {
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
},
}
`;
exports[`most types: Object with Int8Array 1`] = `
{
"a": 1,
"b": Int8Array [
123,
-89,
4,
34,
],
}
`;
exports[`most types: Object with String with property 1`] = `
{
"a": String {},
}
`;
exports[`most types: Object with empty Buffer 1`] = `
{
"a": {
"data": [],
"type": "Buffer",
},
}
`;
exports[`most types: Object with empty String 1`] = `
{
"a": String {},
}
`;
exports[`most types: Object with empty object 1`] = `
{
"a": {},
}
`;
exports[`most types: Object2 1`] = `
{
"a": 1,
"b": 2,
}
`;
exports[`most types: Promise 1`] = `Promise {}`;
exports[`most types: RegExp 1`] = `/hello/`;
exports[`most types: Set 1`] = `Set {}`;
exports[`most types: Set2 1`] = `
Set {
1,
2,
3,
4,
5,
6,
7,
8,
9,
}
`;
exports[`most types: String 1`] = `
String {
"0": "h",
"1": "e",
"2": "l",
"3": "l",
"4": "o",
}
`;
exports[`most types: String with property 1`] = `String {}`;
exports[`most types: Uint8Array 1`] = `Uint8Array []`;
exports[`most types: Uint8ClampedArray 1`] = `Uint8ClampedArray []`;
exports[`most types: Uint16Array 1`] = `Uint16Array []`;
exports[`most types: Uint32Array 1`] = `Uint32Array []`;
exports[`most types: WeakMap 1`] = `WeakMap {}`;
exports[`most types: WeakSet 1`] = `WeakSet {}`;
exports[`most types: arrow function 1`] = `[Function]`;
exports[`most types: empty map 1`] = `Map {}`;
exports[`most types: nested object with Buffer 1`] = `
{
"a": {
"b": {
"data": [
104,
101,
108,
108,
111,
],
"type": "Buffer",
},
},
}
`;
exports[`most types: nested object with empty Buffer 1`] = `
{
"a": {
"b": {
"data": [],
"type": "Buffer",
},
},
}
`;
exports[`most types: nested object with empty Int8Array 1`] = `
{
"a": {
"b": Int8Array [],
},
}
`;
exports[`most types: null 1`] = `null`;
exports[`most types: string 1`] = `"hello string"`;
exports[`most types: testing 4 1`] = `6`;
exports[`most types: testing 4 2`] = `4`;
exports[`most types: testing 5 1`] = `5`;
exports[`most types: testing 7 1`] = `7`;
exports[`most types: testing 7 2`] = `9`;
exports[`most types: testing 7 3`] = `8`;
exports[`most types: undefined 1`] = `undefined`;
exports[`snapshots dollars 1`] = `
exports[`snapshots don't grow file on error 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"$"\`;
"
`;
exports[\`t1 1\`] = \`"abc def ghi jkl"\`;
exports[`snapshots backslash 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`t2 1\`] = \`"abc\\\`def"\`;
exports[\`abc 1\`] = \`"\\\\"\`;
"
`;
exports[`snapshots dollars curly 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"\\\${}"\`;
"
`;
exports[`snapshots dollars curly 2 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"\\\${"\`;
"
`;
exports[`snapshots stuff 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`
"æ™
!!!!*5897yhduN"'\\\`Il"
\`;
"
`;
exports[`snapshots stuff 2 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`
"æ™
!!!!*5897yh!uN"'\\\`Il"
\`;
"
`;
exports[`snapshots regexp 1 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`/\\\${1..}/\`;
"
`;
exports[`snapshots regexp 2 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`/\\\${2..}/\`;
"
`;
exports[`snapshots string 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"abc"\`;
"
`;
exports[`snapshots string with newline 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`
"qwerty
ioup"
\`;
"
`;
exports[`snapshots null byte 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"1 \\x00"\`;
"
`;
exports[`snapshots null byte 2 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"2 \\x00"\`;
"
`;
exports[`snapshots backticks 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"This is \\\`wrong\\\`"\`;
"
`;
exports[`snapshots unicode 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"😊abc\\\`\\\${def} <20>, <20> "\`;
"
`;
exports[`snapshots jest newline oddity 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`
"
"
\`;
exports[\`t3 1\`] = \`"abc def ghi"\`;
"
`;
@@ -495,24 +387,6 @@ exports[\`abc 1\`] = \`"hello"\`;
"
`;
exports[`snapshots grow file for new snapshot 2`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"hello"\`;
exports[\`def 1\`] = \`"hello"\`;
"
`;
exports[`snapshots grow file for new snapshot 3`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"goodbye"\`;
exports[\`def 1\`] = \`"hello"\`;
"
`;
exports[`snapshots backtick in test name 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
@@ -534,60 +408,6 @@ exports[\`Should work 1\`] = \`"This is \\\`wrong\\\`"\`;
"
`;
exports[`snapshots #15283 unicode 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`Should work 1\`] = \`"😊This is \\\`wrong\\\`"\`;
"
`;
exports[`snapshots replaces file that fails to parse when update flag is used 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`t1 1\`] = \`"abc def ghi jkl"\`;
exports[\`t2 1\`] = \`"abc\\\`def"\`;
exports[\`t3 1\`] = \`"abc def ghi"\`;
"
`;
exports[`snapshots property matchers 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`
{
"createdAt": Any<Date>,
"id": Any<Number>,
"name": "LeBron James",
}
\`;
"
`;
exports[`inline snapshots grow file for new snapshot 1`] = `
"
test("abc", () => { expect("hello").toMatchInlineSnapshot(\`"hello"\`) });
"
`;
exports[`inline snapshots backtick in test name 1`] = `"test("\`", () => {expect("abc").toMatchInlineSnapshot(\`"abc"\`);})"`;
exports[`inline snapshots dollars curly in test name 1`] = `"test("\${}", () => {expect("abc").toMatchInlineSnapshot(\`"abc"\`);})"`;
exports[`inline snapshots #15283 1`] = `
"it("Should work", () => {
expect(\`This is \\\`wrong\\\`\`).toMatchInlineSnapshot(\`"This is \\\`wrong\\\`"\`);
});"
`;
exports[`snapshots unicode surrogate halves 1`] = `
"// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
exports[\`abc 1\`] = \`"😊abc\\\`\\\${def} <20>, <20> "\`;
"
`;
exports[`error inline snapshots 1`] = `"hello"`;
exports[`error inline snapshots 2`] = `undefined`;