{"record":{"id":"435aa1fcb9777218","repo":"vitest-dev/vitest","slug":"signature-test-name-fn-was-deprecated","errorCode":null,"errorMessage":"Signature \"test(name, fn, { ... })\" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.","messagePattern":"Signature \"test\\(name, fn, (.+?)\\)\" was deprecated in Vitest 3 and removed in Vitest 4\\. Please, provide options as a second argument instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/runner/suite.ts","lineNumber":267,"sourceCode":"export function createSuiteHooks(): SuiteHooks {\n  return {\n    beforeAll: [],\n    afterAll: [],\n    beforeEach: [],\n    afterEach: [],\n    aroundEach: [],\n    aroundAll: [],\n  }\n}\n\nconst POSITIVE_INFINITY = Number.POSITIVE_INFINITY\n\nfunction parseArguments<T extends (...args: any[]) => any>(\n  optionsOrFn: T | object | undefined,\n  timeoutOrTest: T | number | undefined,\n) {\n  if (timeoutOrTest != null && typeof timeoutOrTest === 'object') {\n    throw new TypeError(`Signature \"test(name, fn, { ... })\" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`)\n  }\n\n  let options: TestOptions = {}\n  let fn: T | undefined\n\n  // it('', () => {}, 1000)\n  if (typeof timeoutOrTest === 'number') {\n    options = { timeout: timeoutOrTest }\n  }\n  // it('', { retry: 2 }, () => {})\n  else if (typeof optionsOrFn === 'object') {\n    options = optionsOrFn\n  }\n\n  if (typeof optionsOrFn === 'function') {\n    if (typeof timeoutOrTest === 'function') {\n      throw new TypeError(\n        'Cannot use two functions as arguments. Please use the second argument for options.',","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/runtime/runner/suite.ts#L249-L285","documentation":"TypeError thrown by parseArguments when the third positional argument to test()/it() is an object. Vitest 3 deprecated the `test(name, fn, { options })` signature and Vitest 4 removed it; options must now be the second argument: `test(name, { options }, fn)`. The check keys off `typeof timeoutOrTest === 'object'`.","triggerScenarios":"Writing `test('x', () => {}, { retry: 2 })`; using a shared config object as the third argument; copy-pasting Vitest 2/3 examples that predate the signature change.","commonSituations":"Upgrading a codebase from Vitest 1/2/3 to Vitest 4; using outdated documentation or AI-generated snippets with the old signature.","solutions":["Reorder to the new signature: `test('x', { retry: 2 }, () => {})`.","Use a codemod or grep for `test(.*,.*,.*{` to find all occurrences and rewrite.","If you need only a timeout, the numeric third arg is still allowed: `test('x', fn, 1000)`."],"exampleFix":"// before (removed in v4)\ntest('x', () => {}, { retry: 2, timeout: 5000 })\n\n// after\ntest('x', { retry: 2, timeout: 5000 }, () => {})","handlingStrategy":"validation","validationCode":"// Before test(), check argument shape:\nfunction safeTest(name, optsOrFn, optsOrTest) {\n  if (typeof optsOrFn === 'function' && optsOrTest && typeof optsOrTest === 'object') {\n    throw new TypeError('Use test(name, options, fn) in Vitest 4')\n  }\n  return test(name, optsOrFn, optsOrTest)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt the Vitest 4 signature: test(name, options, fn).","Grep the codebase for `test(.*,.*,.*{` after major upgrades.","Keep a codemod or eslint rule that flags object-as-third-arg."],"tags":["api-signature","migration","v4","deprecated-api"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}