alias
- Type:
Record<string, string> | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>
Define custom aliases when running inside tests. They will be merged with aliases from resolve.alias.
WARNING
Vitest uses Vite SSR primitives to run tests which has certain pitfalls.
- Aliases affect only modules imported directly with an
importkeyword by an inlined module (all source code is inlined by default). - Vitest does not support aliasing
requirecalls. - If you are aliasing an external dependency (e.g.,
react->preact), you may want to alias the actualnode_modulespackages instead to make it work for externalized dependencies. Both Yarn and pnpm support aliasing via thenpm:prefix.