Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(config,vitest-environment): directly import peerDeps#1617

Merged
danielroe merged 5 commits intomainnuxt/test-utils:mainfrom
fix/importsnuxt/test-utils:fix/importsCopy head branch name to clipboard
Mar 14, 2026
Merged

fix(config,vitest-environment): directly import peerDeps#1617
danielroe merged 5 commits intomainnuxt/test-utils:mainfrom
fix/importsnuxt/test-utils:fix/importsCopy head branch name to clipboard

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

this aims to resolve issues with pnpm's https://pnpm.io/11.x/global-virtual-store and importing 'unexpectedly' a dependency that hasn't been declared with a peerDep entry.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 14, 2026

Warning

Rate limit exceeded

@danielroe has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9488427f-c45a-4114-a3a1-91f4bf720f0a

📥 Commits

Reviewing files that changed from the base of the PR and between 547dbec and 1faef2b.

📒 Files selected for processing (1)
  • src/config.ts
📝 Walkthrough

Walkthrough

Adds ignoreWorkspaceRootCheck: true to pnpm-workspace.yaml. Replaces uses of a local importModule helper with direct dynamic imports in three files: src/environments/vitest/env/happy-dom.ts, src/environments/vitest/env/jsdom.ts, and src/vitest-wrapper/cli.ts. The happy-dom import removes an explicit type cast; the jsdom import retains its type assertion. The vitest wrapper now imports vitest/node directly. No exported/public API signatures or runtime initialization/teardown logic were changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly relates to the main change: replacing indirect imports via local-pkg wrapper with direct imports of peer dependencies (happy-dom, jsdom, vitest/node) and configuring pnpm workspace settings.
Description check ✅ Passed The description accurately references the changeset's intent: addressing pnpm's global virtual store issues by ensuring peer dependencies are imported directly rather than through indirect mechanisms.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/imports
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/environments/vitest/env/jsdom.ts (1)

7-7: Add error handling for missing jsdom optional peer dependency to match the existing pattern used for other optional peers (like playwright-core in src/e2e/browser.ts).

At Line 7, wrap the import in a try-catch block and throw a descriptive error with installation guidance if the module is not found:

Proposed patch
-  const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom')
+  let jsdomModule: typeof import('jsdom')
+  try {
+    jsdomModule = await import('jsdom')
+  }
+  catch (error) {
+    throw new Error(
+      'Missing optional peer dependency "jsdom". Install it in your project (e.g. `pnpm add -D jsdom`).',
+      { cause: error as Error },
+    )
+  }
+  const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = jsdomModule

Note: src/environments/vitest/env/happy-dom.ts has the same issue and should receive the same treatment.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/environments/vitest/env/jsdom.ts` at line 7, Wrap the dynamic import of
jsdom in a try-catch so missing optional peer dependency is handled: replace the
direct await import('jsdom') that destructures CookieJar, JSDOM, ResourceLoader,
VirtualConsole with a try block and in catch throw a descriptive Error advising
to install jsdom (e.g. "jsdom is required for this environment — install with
`npm i -D jsdom`"), preserving original variable names (CookieJar, JSDOM,
ResourceLoader, VirtualConsole) for use after the import; apply the identical
try-catch pattern to the similar import in the happy-dom environment file as
well.
pnpm-workspace.yaml (1)

22-22: Document the rationale for ignoreWorkspaceRootCheck: true to prevent accidental root-level dependency drift.

At Line 22, disabling this guard allows pnpm add ... to modify the workspace root package.json without the explicit -w/--workspace-root flag. While this reduces friction if root-level tooling dependencies are intentional, it increases the risk of silently accumulating dependencies that should be scoped to specific packages, weakening workspace boundaries. Add a comment in pnpm-workspace.yaml or update contributing docs to clarify why this is disabled.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pnpm-workspace.yaml` at line 22, Add a short rationale near the existing
setting by commenting why ignoreWorkspaceRootCheck: true is enabled: state that
it permits intentional root-level tooling installs (e.g., CI/tools) and that
contributors should prefer package-scoped dependencies unless adding global
workspace tools; also reference the contributing docs where you describe the
policy and the required use of -w/--workspace-root when adding root deps. Update
the pnpm-workspace.yaml to include this explanatory comment adjacent to
ignoreWorkspaceRootCheck: true and add or update the contributing guide section
on workspace root dependency policy to prevent accidental root-level dependency
drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pnpm-workspace.yaml`:
- Line 22: Add a short rationale near the existing setting by commenting why
ignoreWorkspaceRootCheck: true is enabled: state that it permits intentional
root-level tooling installs (e.g., CI/tools) and that contributors should prefer
package-scoped dependencies unless adding global workspace tools; also reference
the contributing docs where you describe the policy and the required use of
-w/--workspace-root when adding root deps. Update the pnpm-workspace.yaml to
include this explanatory comment adjacent to ignoreWorkspaceRootCheck: true and
add or update the contributing guide section on workspace root dependency policy
to prevent accidental root-level dependency drift.

In `@src/environments/vitest/env/jsdom.ts`:
- Line 7: Wrap the dynamic import of jsdom in a try-catch so missing optional
peer dependency is handled: replace the direct await import('jsdom') that
destructures CookieJar, JSDOM, ResourceLoader, VirtualConsole with a try block
and in catch throw a descriptive Error advising to install jsdom (e.g. "jsdom is
required for this environment — install with `npm i -D jsdom`"), preserving
original variable names (CookieJar, JSDOM, ResourceLoader, VirtualConsole) for
use after the import; apply the identical try-catch pattern to the similar
import in the happy-dom environment file as well.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3daf8177-ec84-48a4-a061-fbd6ac725862

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa5e87 and 13782e1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • pnpm-workspace.yaml
  • src/environments/vitest/env/happy-dom.ts
  • src/environments/vitest/env/jsdom.ts
  • src/vitest-wrapper/cli.ts

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/test-utils/@nuxt/test-utils@1617
npm i https://pkg.pr.new/nuxt/test-utils/vitest-environment-nuxt@1617

commit: 16d9594

@danielroe danielroe merged commit c56f77a into main Mar 14, 2026
7 checks passed
@danielroe danielroe deleted the fix/imports branch March 14, 2026 23:40
@github-actions github-actions Bot mentioned this pull request Mar 14, 2026
@github-actions github-actions Bot mentioned this pull request Apr 8, 2026
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.