{"id":"06526f4c2164526a","repo":"jestjs/jest","slug":"matcherhint-expected-properties-must-be-an-06526f","errorCode":null,"errorMessage":"${matcherHint(...)} Expected properties must be an object\n${printWithType('Expected properties', propertiesOrSnapshot, printExpected)}","messagePattern":"(.+?) Expected properties must be an object\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-snapshot/src/index.ts","lineNumber":238,"sourceCode":"\n  const length = arguments.length;\n  if (length === 2 && typeof propertiesOrSnapshot === 'string') {\n    inlineSnapshot = propertiesOrSnapshot;\n  } else if (length >= 2) {\n    const options: MatcherHintOptions = {\n      isNot: this.isNot,\n      promise: this.promise,\n    };\n    if (length === 3) {\n      options.secondArgument = SNAPSHOT_ARG;\n      options.secondArgumentColor = noColor;\n    }\n\n    if (\n      typeof propertiesOrSnapshot !== 'object' ||\n      propertiesOrSnapshot === null\n    ) {\n      throw new Error(\n        matcherErrorMessage(\n          matcherHint(matcherName, undefined, PROPERTIES_ARG, options),\n          `Expected ${EXPECTED_COLOR('properties')} must be an object`,\n          printWithType(\n            'Expected properties',\n            propertiesOrSnapshot,\n            printExpected,\n          ),\n        ),\n      );\n    }\n\n    if (length === 3 && typeof inlineSnapshot !== 'string') {\n      throw new Error(\n        matcherErrorMessage(\n          matcherHint(matcherName, undefined, PROPERTIES_ARG, options),\n          'Inline snapshot must be a string',\n          printWithType('Inline snapshot', inlineSnapshot, serialize),","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-snapshot/src/index.ts#L220-L256","documentation":"Thrown by `toMatchInlineSnapshot` (index.ts:234-249) when the call passes a `propertiesOrSnapshot` argument that is neither a string (treated as the inline snapshot) nor a non-null object (treated as expected properties). Same shape as the toMatchSnapshot guard but for inline variant.","triggerScenarios":"`expect(x).toMatchInlineSnapshot(42)`, `expect(x).toMatchInlineSnapshot(null, 'snapshot')`, or `toMatchInlineSnapshot(true)`.","commonSituations":"Passing a primitive where an object or template-literal string is expected. Variable mistakenly null.","solutions":["Pass an object for properties, or a backtick string for the inline snapshot.","If you don't want properties, drop the argument entirely so Jest writes the snapshot for you."],"exampleFix":"// before\nexpect(x).toMatchInlineSnapshot(123);\n\n// after\nexpect(x).toMatchInlineSnapshot(`123`);\n// or, with properties:\nexpect(x).toMatchInlineSnapshot({ code: 123 });","handlingStrategy":"type-guard","validationCode":"if (arg != null && typeof arg !== 'object' && typeof arg !== 'string') {\n  throw new Error('toMatchInlineSnapshot needs an object or string');\n}\nexpect(x).toMatchInlineSnapshot(arg);","typeGuard":"function isInlineSnapshotArg(v: unknown): v is object | string {\n  return v == null || typeof v === 'object' || typeof v === 'string';\n}","tryCatchPattern":null,"preventionTips":["Author inline snapshot calls without arguments first; let Jest write the literal via -u.","Pass properties as object literals at the call site."],"tags":["snapshot","matcher","argument-validation","inline-snapshot"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}