{"record":{"id":"0ef5ec45c0492cea","repo":"remix-run/remix","slug":"matchername-requires-a-mock-function-with-a-mo","errorCode":null,"errorMessage":"${matcherName} requires a mock function with a .mock.calls property","messagePattern":"(.+?) requires a mock function with a \\.mock\\.calls property","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"packages/assert/src/lib/expect.ts","lineNumber":84,"sourceCode":"\ninterface MockShape {\n  mock: {\n    calls: Array<{ arguments: unknown[] }>\n  }\n}\n\nfunction isMockFn(value: unknown): value is MockShape {\n  return (\n    typeof value === 'function' &&\n    typeof (value as any).mock === 'object' &&\n    (value as any).mock != null &&\n    Array.isArray((value as any).mock.calls)\n  )\n}\n\nfunction getMockCalls(received: unknown, matcherName: string): Array<{ arguments: unknown[] }> {\n  if (!isMockFn(received)) {\n    throw new AssertionError({\n      message: `${matcherName} requires a mock function with a .mock.calls property`,\n      operator: matcherName,\n    })\n  }\n  return received.mock.calls\n}\n\nfunction checkErrorMatch(error: any, expected: unknown): boolean {\n  if (expected === undefined) return true\n  if (typeof expected === 'function') {\n    if (expected.prototype != null && expected.prototype instanceof Error) {\n      return error instanceof (expected as new (...args: any[]) => Error)\n    }\n    return Boolean((expected as (e: unknown) => unknown)(error))\n  }\n  if (expected instanceof Error) {\n    return error?.message === expected.message\n  }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/assert/src/lib/expect.ts#L66-L102","documentation":"The `--step` option must be a positive integer (1, 2, 3, ...). `parseStepOption` converts the string with `Number()` and rejects anything that is not an integer >= 1 — zero, negatives, decimals, NaN, or empty strings.","triggerScenarios":"Passing `--step 0`, `--step -1`, `--step 1.5`, `--step abc`, or `--step \"\"` to a db command accepting `--step`; `Number(value)` yields NaN or fails the integer/positivity checks.","commonSituations":"Scripts computing step counts dynamically that produce 0 or empty values; copy-pasting from docs; passing decimals expecting partial steps.","solutions":["Use a positive whole number: `--step 3`","Guard scripted values (e.g. `[ \"$step\" -ge 1 ]`) before invoking the CLI","Omit `--step` to use the default behavior"],"exampleFix":"# before\nremix db rollback --step 0\n# after\nremix db rollback --step 1","handlingStrategy":"validation","validationCode":"let step = Number(process.env.DB_STEP ?? 1);\nif (!Number.isInteger(step) || step < 1) step = 1;\nrun(['remix','db','rollback','--step',String(step)])","typeGuard":"function isValidStep(v: string): boolean {\n  let n = Number(v);\n  return v.trim() !== '' && Number.isInteger(n) && n >= 1;\n}","tryCatchPattern":null,"preventionTips":["Validate numeric flags in wrapper scripts","Treat empty computed values as 'not provided'","Omit --step for defaults"],"tags":["cli","database","option-validation"],"backgroundTag":"invalid-option-value","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}