{"record":{"id":"388826a8a8fe70e1","repo":"jquense/yup","slug":"test-is-a-required-parameters","errorCode":null,"errorMessage":"`test` is a required parameters","messagePattern":"`test` is a required parameters","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/schema.ts","lineNumber":784,"sourceCode":"  test(...args: any[]) {\n    let opts: TestConfig;\n\n    if (args.length === 1) {\n      if (typeof args[0] === 'function') {\n        opts = { test: args[0] };\n      } else {\n        opts = args[0];\n      }\n    } else if (args.length === 2) {\n      opts = { name: args[0], test: args[1] };\n    } else {\n      opts = { name: args[0], message: args[1], test: args[2] };\n    }\n\n    if (opts.message === undefined) opts.message = locale.default;\n\n    if (typeof opts.test !== 'function')\n      throw new TypeError('`test` is a required parameters');\n\n    let next = this.clone();\n    let validate = createValidation(opts);\n\n    let isExclusive =\n      opts.exclusive || (opts.name && next.exclusiveTests[opts.name] === true);\n\n    if (opts.exclusive) {\n      if (!opts.name)\n        throw new TypeError(\n          'Exclusive tests must provide a unique `name` identifying the test',\n        );\n    }\n\n    if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;\n\n    next.tests = next.tests.filter((fn) => {\n      if (fn.OPTIONS!.name === opts.name) {","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/jquense/yup/blob/ff31eee8a2b10c938bb3a22544d9e33957a8cf01/src/schema.ts#L766-L802","documentation":"Schema.test() accepts either an options object or positional (name, message, test) arguments, and the `test` option must be the actual predicate function. This TypeError is thrown when opts.test is not a function after argument normalization.","triggerScenarios":"Calling .test('myCheck') with only a name, .test('name', 'message') with no test fn, passing a non-function (e.g. a boolean or undefined) as the test argument, or an options object missing the `test` key.","commonSituations":"Forgetting to supply the predicate when only customizing the message; passing a named reference to an undefined function; refactoring that removed the test function but left the arguments.","solutions":["Pass the test function: .test('name', 'message', value => boolean)","Use the options-object form: .test({ name, message, test: fn })","Check that the referenced function is defined and imported","Use .required() instead if the goal was a built-in check, not a custom test"],"exampleFix":"// before\nyup.string().test('isUpper', 'must be uppercase');\n// after\nyup.string().test('isUpper', 'must be uppercase', v => v === v?.toUpperCase());","handlingStrategy":"validation","validationCode":"if (typeof testFn !== 'function') throw new Error('test() requires a predicate function');\nschema.test({ name: 'myTest', message: 'msg', test: testFn });","typeGuard":"function isTestOptions(o: unknown): o is { name?: string; message?: string; test: (v: any) => boolean } {\n  return typeof (o as any)?.test === 'function';\n}","tryCatchPattern":"try { schema.test(opts as any); } catch (e) { if (/`test` is a required/.test(e.message)) console.warn('skipping invalid test'); else throw e; }","preventionTips":["Prefer the options-object form .test({ name, message, test }) — it's self-documenting","Check that referenced predicate functions are imported/defined","Never pass undefined placeholders for the test argument"],"tags":["api-misuse","typeerror","custom-test"],"backgroundTag":"missing-required-argument","analyzedSha":"ff31eee8a2b10c938bb3a22544d9e33957a8cf01","analyzedAt":"2026-08-31T21:51:03.773Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}