Skip to content

fix(@angular/build): resolve Vitest artifacts when workspace root is aliased - #34714

Merged
alan-agius4 merged 5 commits into
angular:mainfrom
alan-agius4:fix-e2e-vitest-saucelabs
Nov 13, 2026
Merged

alan-agius4 merged 5 commits into
angular:mainfrom
alan-agius4:fix-e2e-vitest-saucelabs

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Starting in Vite 8.3.8 (vitejs/vite@b643046), windowsLazyRealpathSync calls fs.realpathSync.native synchronously on config.root, which resolves Windows subst drives and symlinks to their underlying physical path (e.g., D:/.../test-project) while the Angular CLI's workspaceRoot retains the logical path (X:\test-project).

This caused three issues during Vitest execution on aliased roots:

  1. Vitest resolves relative setupFiles and test files against vitestConfig.root, which did not match workspaceRoot or the testFileToEntryPoint map in angular:test-in-memory-provider.
  2. Passing absolute workspaceRoot paths in test.include caused tinyglobby (running with cwd: vitestConfig.root) to produce cross-drive relative paths (../../../../X:/...) that resolved to invalid paths (D:/X:/...).
  3. Resolving virtual setup files under vitestConfig.root while resolving on-disk spec files under workspaceRoot caused bare package imports (such as @angular/core/testing) to be loaded twice from both drives.

To fix this:

  • Pass workspace-relative paths in test.include in VitestExecutor.
  • Rebase workspaceRoot, testFileToEntryPoint, and setupFileSet in createVitestPlugins (configureVitest) when vitestConfig.root differs from workspaceRoot.

…aliased

In Vitest 5.1.0, `vitestConfig.root` inherits `viteConfig.root`, which resolves symlinks and Windows `subst` drives via `realpathSync`. Normalize paths under `vitestConfig.root` back to `workspaceRoot` in the in-memory provider plugin so internal setup files and build artifacts resolve consistently.
@angular-robot angular-robot Bot added area: build & ci Related the build and CI infrastructure of the project area: @angular/build labels Nov 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces path normalization to workspace roots in Vitest plugins to handle scenarios where vitestConfig.root differs from workspaceRoot (such as symlinks or subst drives), along with corresponding unit tests. It also updates E2E test configurations to support dynamic sharding, allows bulk package installation in E2E tests, and increases the test timeout from 4 to 8 minutes. Regarding the review feedback, an issue was identified in the path normalization logic where checking relativeToVitestRoot.startsWith('..') could incorrectly match valid files or directories starting with .. (e.g., ..foo/bar.ts). It is recommended to explicitly check if the path is exactly .. or starts with .. followed by a path separator.

@alan-agius4 alan-agius4 added target: rc This PR is targeted for the next release-candidate action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 13, 2026
@alan-agius4
alan-agius4 force-pushed the fix-e2e-vitest-saucelabs branch from 5cbb43e to 0813dc5 Compare November 13, 2026 10:44
@alan-agius4
alan-agius4 force-pushed the fix-e2e-vitest-saucelabs branch from 84819ed to e6d76c8 Compare November 13, 2026 11:31
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 13, 2026
@alan-agius4
alan-agius4 merged commit be51753 into angular:main Nov 13, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix-e2e-vitest-saucelabs branch November 13, 2026 12:15
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build area: build & ci Related the build and CI infrastructure of the project target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants