Skip to content

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

Open
yamachi4416 wants to merge 4 commits 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 4 commits 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: baee3b9

@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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: db298f1f-8f9d-40ca-a6ad-cb7717506dfb

📥 Commits

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

📒 Files selected for processing (2)
  • src/config.ts
  • src/runtime/shared/environment.ts

📝 Walkthrough

Walkthrough

The PR adds configurable Nuxt app root and teleport settings to resolved vitest environment options, refactors window setup to create those DOM nodes through a shared helper, and updates example apps and tests to cover teleport rendering plus custom root and teleport attributes. It also adds a new teleport fixture component and related pages, and enables stripInternal in TypeScript config.

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 title clearly matches the main change: improving app.root and app.teleports HTML tag setup.
Description check ✅ Passed The description is directly about the same Nuxt test-utils HTML tag and teleport setup changes.
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.
✨ 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.

@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
Comment thread src/config.ts
Comment on lines +153 to +171
nuxtConfig: {
runtimeConfig: applyEnv(structuredClone(options.nuxt.options.runtimeConfig), {
prefix: 'NUXT_',
env: await setupDotenv(defu(loadNuxtOptions.dotenv, {
cwd: rootDir,
fileName: '.env.test',
})),
}),
routeRules: defu(
{},
options.nuxt.options.routeRules,
options.nuxt.options.nitro?.routeRules,
),
app: {
rootAttrs: options.nuxt.options.app.rootAttrs,
rootTag: options.nuxt.options.app.rootTag,
teleportAttrs: options.nuxt.options.app.teleportAttrs,
teleportTag: options.nuxt.options.app.teleportTag,
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could end users have been dependent on the previous structure? might this be a breaking change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you!
I restored the original structure. definitely, it might be a breaking change if any end user is using this.

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