{"record":{"id":"07ac75bf4b088621","repo":"vitest-dev/vitest","slug":"cannot-resolve-user-fixtures-see-errors-for-more","errorCode":null,"errorMessage":"Cannot resolve user fixtures. See errors for more information.","messagePattern":"Cannot resolve user fixtures\\. See errors for more information\\.","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/runner/fixture.ts","lineNumber":234,"sourceCode":"          continue\n        }\n        if (depName === fixture.name && !fixture.parent) {\n          errors.push(new FixtureDependencyError(`The \"${fixture.name}\" fixture depends on itself, but does not have a base implementation.`))\n          continue\n        }\n\n        if (TestFixtures._fixtureScopes.indexOf(fixture.scope) > TestFixtures._fixtureScopes.indexOf(dep.scope)) {\n          errors.push(new FixtureDependencyError(`The ${fixture.scope} \"${fixture.name}\" fixture cannot depend on a ${dep.scope} fixture \"${dep.name}\".`))\n          continue\n        }\n      }\n    }\n\n    if (errors.length === 1) {\n      throw errors[0]\n    }\n    else if (errors.length > 1) {\n      throw new AggregateError(errors, 'Cannot resolve user fixtures. See errors for more information.')\n    }\n    return registrations\n  }\n}\n\nconst cleanupFnArrayMap = new WeakMap<\n  object,\n  Array<() => void | Promise<void>>\n>()\n\nexport async function callFixtureCleanup(context: object): Promise<void> {\n  const cleanupFnArray = cleanupFnArrayMap.get(context) ?? []\n  for (const cleanup of cleanupFnArray.reverse()) {\n    await cleanup()\n  }\n  cleanupFnArrayMap.delete(context)\n}\n","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/runtime/runner/fixture.ts#L216-L252","documentation":"An AggregateError wrapping two or more fixture-resolution errors collected during TestFixtures.resolve. Each inner error describes a specific problem (unknown dependency, self-dependency, scope violation). Vitest batches them so you see all fixture mistakes at once instead of fixing them one at a time. Inspect `error.errors` to read the individual causes.","triggerScenarios":"Declaring several fixtures whose dependencies are invalid simultaneously: e.g., a fixture depending on an unregistered name, another depending on itself, and a third with a scope mismatch. All are detected in the single resolution pass.","commonSituations":"Large fixture files where multiple typos or refactoring mistakes accumulate; mixing test/worker/file scopes incorrectly across several fixtures; deleting a fixture but leaving references in others.","solutions":["Read `err.errors` (AggregateError) to list each underlying FixtureDependencyError.","Fix each referenced fixture: register missing ones, remove self-references, correct scope ordering.","Re-run; resolution is idempotent and will re-scan after edits."],"exampleFix":"// before\nconst fixtures = {\n  a: ({ b }) => {},     // b unknown\n  c: ({ c }) => {},     // self-dep, no parent\n  d: test.fn(async ({ use }) => use(1), { scope: 'test' }),\n  e: test.fn(async ({ d, use }) => use(d), { scope: 'worker' }), // worker depends on test\n}\n\n// after: fix each cause, then re-resolve","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await runWithFixtures(fn, options)\n} catch (e) {\n  if (e instanceof AggregateError) {\n    for (const inner of e.errors) console.error(inner.message)\n  } else throw e\n}","preventionTips":["Keep fixture dependency graphs shallow and acyclic.","Run a small fixture-graph test in CI that instantiates all fixtures.","Use TypeScript types for fixture dependencies so missing names surface at compile time."],"tags":["fixtures","dependency-injection","aggregate-error"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}