From 9087f28245f85fb813b8671c3649b6a6377f9a03 Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 26 Feb 2026 11:16:09 -0500 Subject: [PATCH] test(snapshot-testing): configurable member value overrides --- .changeset/plenty-snails-obey.md | 5 +++++ packages/snapshot-testing/src/index.ts | 1 + .../src/structure/createFromSchema.ts | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changeset/plenty-snails-obey.md diff --git a/.changeset/plenty-snails-obey.md b/.changeset/plenty-snails-obey.md new file mode 100644 index 00000000000..9def7430133 --- /dev/null +++ b/.changeset/plenty-snails-obey.md @@ -0,0 +1,5 @@ +--- +"@smithy/snapshot-testing": patch +--- + +additional member value overrides for snapshot data generator diff --git a/packages/snapshot-testing/src/index.ts b/packages/snapshot-testing/src/index.ts index 59a478d35fa..2e57d80609c 100644 --- a/packages/snapshot-testing/src/index.ts +++ b/packages/snapshot-testing/src/index.ts @@ -1 +1,2 @@ export { SnapshotRunner } from "./SnapshotRunner"; +export { customFields } from "./structure/createFromSchema"; diff --git a/packages/snapshot-testing/src/structure/createFromSchema.ts b/packages/snapshot-testing/src/structure/createFromSchema.ts index d03d1a64758..4903fbd7af1 100644 --- a/packages/snapshot-testing/src/structure/createFromSchema.ts +++ b/packages/snapshot-testing/src/structure/createFromSchema.ts @@ -14,6 +14,10 @@ export function createFromSchema(schema: $SchemaRef, path = ""): any { const $ = NormalizedSchema.of(schema); const memberName = $.isMemberSchema() ? $.getMemberName() : "____"; + if (customFields[memberName]) { + return customFields[memberName]; + } + const qualifiedName = $.getName(true) ?? "UnknownSchema!"; path += " -> " + qualifiedName + "$" + memberName; @@ -23,7 +27,7 @@ export function createFromSchema(schema: $SchemaRef, path = ""): any { if ($.isIdempotencyToken()) { return "00000000-0000-4000-8000-000000000000"; } - return customFields[memberName] ?? "__" + memberName + "__"; + return "__" + memberName + "__"; } else if ($.isNumericSchema()) { return 0; } else if ($.isBigIntegerSchema()) { @@ -107,7 +111,13 @@ export function createFromSchema(schema: $SchemaRef, path = ""): any { return "UNSUPPORTED_SCHEMA_TYPE"; } -const customFields: Record = { +/** + * Overrides the generated values for members with matching names. + * @internal + */ +export const customFields: Record = { PredictEndpoint: "https://localhost", ChecksumAlgorithm: "CRC64NVME", + AccountId: "123456789012", + OutpostId: "OutpostId", };