{"record":{"id":"91baaebd1d695f71","repo":"denoland/deno","slug":"err-invalid-arg-type-91baae","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"The \"options.serializers\" property must be an instance of Array. Received ${actual}","messagePattern":"The \"options\\.serializers\" property must be an instance of Array\\. Received (.+?)","errorType":"validation","errorClass":"ERR_INVALID_ARG_TYPE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/testing.ts","lineNumber":342,"sourceCode":"// `t.assert.fileSnapshot(value, path[, options])`.\n//\n// Without `--test-update-snapshots`, serializes `value` and compares against\n// the contents of the file at `path` using `assert.strictEqual`. With the\n// flag, writes the serialized value to `path` (creating parent directories\n// as needed). Both file paths are CWD-relative, matching Node.\nfunction fileSnapshot(actual, path, options) {\n  validateString(path, \"path\");\n  if (options === undefined) {\n    options = { __proto__: null };\n  } else {\n    validateObject(options, \"options\");\n  }\n  let serializers;\n  if (options.serializers === undefined) {\n    serializers = [defaultFileSnapshotSerializer];\n  } else {\n    if (!ArrayIsArray(options.serializers)) {\n      throw new ERR_INVALID_ARG_TYPE(\n        \"options.serializers\",\n        \"Array\",\n        options.serializers,\n      );\n    }\n    serializers = options.serializers;\n    for (let i = 0; i < serializers.length; i++) {\n      if (typeof serializers[i] !== \"function\") {\n        throw new ERR_INVALID_ARG_TYPE(\n          `options.serializers[${i}]`,\n          \"function\",\n          serializers[i],\n        );\n      }\n    }\n  }\n  let value = actual;\n  try {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/testing.ts#L324-L360","documentation":"In node:test snapshot testing, t.assert.fileSnapshot(value, path, options) validates its options: if options.serializers is supplied it must be an Array (fileSnapshot assigns it element-by-element to run each serializer over the value). Passing anything else — most often a bare serializer function — throws ERR_INVALID_ARG_TYPE naming 'options.serializers' with expected type 'Array'. When omitted, the default file snapshot serializer is used.","triggerScenarios":"t.assert.fileSnapshot(body, 'snap.txt', { serializers: mySerializer }) with a bare function instead of an array; passing a string, object, or null as serializers.","commonSituations":"Developers coming from APIs that accept a single function; copy-pasting a serializer from another test library; refactoring that drops the array brackets around an existing list.","solutions":["Wrap the serializer in an array: { serializers: [mySerializer] }","Omit the serializers option entirely to use the default file snapshot serializer","Order matters: serializers run left-to-right, each receiving the previous one's output — keep the array order intentional"],"exampleFix":"// before\nt.assert.fileSnapshot(body, 'snap.txt', { serializers: mySerializer });\n\n// after\nt.assert.fileSnapshot(body, 'snap.txt', { serializers: [mySerializer] });","handlingStrategy":"validation","validationCode":"function normalizeSerializers(options) {\n  const serializers = options?.serializers;\n  if (serializers === undefined) return undefined;\n  if (!Array.isArray(serializers)) {\n    throw new TypeError('options.serializers must be an Array');\n  }\n  return serializers;\n}\n\nconst serializers = normalizeSerializers(opts);\nt.assert.fileSnapshot(body, 'snap.txt', { serializers });","typeGuard":"const isSerializerArray = (v) =>\n  v === undefined || (Array.isArray(v) && v.every((s) => typeof s === 'function'));","tryCatchPattern":null,"preventionTips":["Always write serializers as an array literal: { serializers: [stripDates] }","Omit the option to use the default snapshot serializer","Centralize serializer lists in one typed constant so every fileSnapshot call shares a validated shape"],"tags":["node-test","snapshot-testing","argument-validation"],"backgroundTag":"invalid-argument-type","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T08:17:14.275Z"}