Skip to content

docs(swc): add vitest alias resolution configuration #3204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

mag123c
Copy link
Contributor

@mag123c mag123c commented Feb 18, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Docs
  • Other... Please describe:

What is the current behavior?

Vitest does not automatically resolve TypeScript path aliases (src/), unlike Jest, which uses moduleNameMapper.
This can lead to dependency resolution errors when running tests

Issue Number: nestjs/nest#14653

What is the new behavior?

  • Updated the SWC documentation to include a fix for Vitest path alias resolution.
  • Added resolve.alias configuration in vitest.config.ts to ensure correct module resolution.
  • Explained why Vitest requires explicit path alias configuration, improving clarity for users.
  • Ensured consistency with Jest’s moduleNameMapper behavior.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This PR improves the official documentation by adding an alias resolution configuration to prevent common Vitest issues when running tests in NestJS projects. This ensures a smoother developer experience and avoids dependency resolution errors.

@kamilmysliwiec kamilmysliwiec merged commit b0b8d77 into nestjs:master Feb 19, 2025
@kamilmysliwiec
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants