Skip to content

feat(runtime): improve app.root and app.teleports html tag setup#1726

Open
yamachi4416 wants to merge 1 commit into
nuxt:mainfrom
yamachi4416:improve-root-and-teleport-tag
Open

feat(runtime): improve app.root and app.teleports html tag setup#1726
yamachi4416 wants to merge 1 commit into
nuxt:mainfrom
yamachi4416:improve-root-and-teleport-tag

Conversation

@yamachi4416

@yamachi4416 yamachi4416 commented Jun 21, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

This PR improves testing setup for html tags for app.root and app.teleport.

  • Added the html tag for <Teleport> target automatically during setup so <Teleport> works by default
  • Applying attributes to html tag app.root and app.teleports improves visual testing
  • Marked environmentOptions.nuxt.rootId as deprecated, as it requires setting app.rootId to the same value and overrides.app.rootAttrs.id or overrides.app.rootId are alternatives

Any feedback or thoughts would be appreciated🙏

@pkg-pr-new

pkg-pr-new Bot commented Jun 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 24d8ac5

@yamachi4416 yamachi4416 force-pushed the improve-root-and-teleport-tag branch from a4e4dac to 24d8ac5 Compare June 21, 2026 01:56
@yamachi4416 yamachi4416 marked this pull request as ready for review June 21, 2026 02:06
@yamachi4416 yamachi4416 requested a review from danielroe as a code owner June 21, 2026 02:06
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR consolidates Nuxt test environment options into a new NuxtEnvironmentResolvedOptions interface whose nuxtConfig field holds runtimeConfig, routeRules, and app (root/teleport tag and attribute settings). getVitestConfigFromNuxt builds this object from Nuxt internals; setupWindow is refactored to use a new createElementAndAppend helper that creates the root and teleport DOM elements with configurable HTML tags and attributes, skipping creation when the element already exists and handling boolean attribute values. A TestTeleport Vue component and supporting pages are added to app-vitest-full, with new mountSuspended/renderSuspended test cases verifying lifecycle-correct teleport DOM presence. Workspace apps app1app3 add rootAttrs, teleportAttrs, rootTag, and teleportTag configurations, each backed by new tests asserting correct element tag names and attributes. tsconfig.json gains stripInternal: true to strip @internal declarations from output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: improving HTML tag setup for app.root and app.teleports elements in the runtime.
Description check ✅ Passed The PR description is directly related to the changeset, explaining the key improvements: automatic teleport target creation, HTML tag attributes configuration, and deprecation of rootId.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runtime/shared/environment.ts`:
- Around line 109-128: The createElementAndAppend function creates elements
without ensuring a default id is set for teleport elements when teleportAttrs is
undefined or lacks an id attribute. This prevents Vue's Teleport component from
finding the target element. Modify the function to assign a default id of
'teleports' to the created element when no id is provided in the attrs
parameter, ensuring this default is set before the element is appended to the
document body. This should follow the same pattern as the root element which
defaults to 'nuxt-test'.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10c41009-5eb5-4b24-aaed-fc6af669bc20

📥 Commits

Reviewing files that changed from the base of the PR and between e1a0f63 and 24d8ac5.

📒 Files selected for processing (14)
  • examples/app-vitest-full/components/TestTeleport.vue
  • examples/app-vitest-full/pages/other/index.vue
  • examples/app-vitest-full/pages/other/teleports.vue
  • examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts
  • examples/app-vitest-full/tests/nuxt/render-suspended.spec.ts
  • examples/app-vitest-workspace/app1/nuxt.config.ts
  • examples/app-vitest-workspace/app1/test/app.nuxt.spec.ts
  • examples/app-vitest-workspace/app2/nuxt.config.ts
  • examples/app-vitest-workspace/app2/test/nuxt/app.spec.ts
  • examples/app-vitest-workspace/app3/test/nuxt/app.spec.ts
  • examples/app-vitest-workspace/app3/vitest.config.ts
  • src/config.ts
  • src/runtime/shared/environment.ts
  • tsconfig.json

Comment thread src/runtime/shared/environment.ts
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