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(runtime-utils): align mount options merge w/ vue-test-utils#1610

Merged
danielroe merged 3 commits intonuxt:mainnuxt/test-utils:mainfrom
yamachi4416:fix/stubbed-global-provideyamachi4416/test-utils:fix/stubbed-global-provideCopy head branch name to clipboard
Mar 15, 2026
Merged

fix(runtime-utils): align mount options merge w/ vue-test-utils#1610
danielroe merged 3 commits intonuxt:mainnuxt/test-utils:mainfrom
yamachi4416:fix/stubbed-global-provideyamachi4416/test-utils:fix/stubbed-global-provideCopy head branch name to clipboard

Conversation

@yamachi4416
Copy link
Copy Markdown
Member

@yamachi4416 yamachi4416 commented Mar 7, 2026

🔗 Linked issue

📚 Description

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 7, 2026

Open in StackBlitz

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

commit: 60bca8e

@yamachi4416 yamachi4416 force-pushed the fix/stubbed-global-provide branch from 3a9fcd0 to 1a32dd0 Compare March 14, 2026 23:48
@yamachi4416 yamachi4416 marked this pull request as ready for review March 14, 2026 23:54
@yamachi4416 yamachi4416 requested a review from danielroe as a code owner March 14, 2026 23:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 14, 2026

📝 Walkthrough

Walkthrough

Adds a new injectable array to the example app by exporting CUSTOM_VUE_PLUGIN_WITH_ARRAY_KEY and VUE_INJECTED_ARRAY_VALUE from the inject-value plugin, and updates a component to inject and render that array. Expands tests: updates injected-value component tests (including stubbing the injected array) and adds a new "mount global options" test suite. Replaces a defu-based merge in src/runtime-utils/utils/suspended.ts with an explicit mergeComponentMountingGlobalOptions helper and applies merged global mounting options when constructing wrapper options.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 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
Description check ✅ Passed The description is directly related to the changeset, identifying the problem (failing test for stubbed global provide) and the solution (aligning merging logic with vue/test-utils).
Title check ✅ Passed The pull request title accurately describes the main change: aligning mount options merge with vue-test-utils in the runtime-utils module.

✏️ 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
📝 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/runtime-utils/utils/suspended.ts (1)

231-238: Potential loss of nested config properties other than globalProperties.

The current merge only explicitly handles globalProperties within config. If options.config contains additional nested objects like compilerOptions, the spread ...options.config will overwrite ...defaults.config entirely for those keys rather than deep-merging them.

Given the test at line 578-599 uses config.compilerOptions and the defaults don't set compilerOptions, this works now. However, if future defaults include compilerOptions, the user-provided values would fully replace defaults instead of merging.

If deep-merging other config sub-properties is intended, consider extending the pattern used for globalProperties.

♻️ Optional: extend deep merge for compilerOptions if needed
     config: {
       ...defaults.config,
       ...options.config,
       globalProperties: {
         ...defaults.config?.globalProperties,
         ...options.config?.globalProperties,
       } as NonNullable<typeof options['config']>['globalProperties'],
+      compilerOptions: {
+        ...defaults.config?.compilerOptions,
+        ...options.config?.compilerOptions,
+      },
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime-utils/utils/suspended.ts` around lines 231 - 238, The config
merge currently only deep-merges globalProperties and shallowly spreads
options.config over defaults.config, which will cause nested config objects
(e.g., compilerOptions) to be overwritten rather than merged; update the merge
logic around config to deep-merge any nested sub-objects you want preserved (at
least include compilerOptions like globalProperties) by merging defaults.config,
options.config, and then individually deep-merging nested keys such as
globalProperties and compilerOptions (referencing the existing defaults.config,
options.config, globalProperties, and compilerOptions symbols) so user-provided
nested settings are merged with defaults rather than replaced.
examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts (1)

601-622: Consider adding tests for mocks and directives global options.

The new mergeComponentMountingGlobalOptions function also handles mocks and directives, but there are no dedicated tests in this suite for those options. While mocks is tested in the existing global.mocks test (line 48-57), adding explicit tests here would ensure comprehensive coverage of the merge behavior.

This is optional since the existing test at line 48 does cover mocks behavior.

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

In `@examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts` around lines
601 - 622, Add explicit tests for global.mocks and global.directives in this
compatibility-mount.spec.ts suite similar to the existing
config.globalProperties test: create a small Component via defineComponent that
uses a mocked property (e.g., this.$mocked or a template reference) and a custom
directive (e.g., v-test that mutates DOM/text), then mount it with options typed
as Options<typeof Component> and compare outputs from mount(...) and await
mountSuspended(...). Ensure the tests exercise the
mergeComponentMountingGlobalOptions behavior by passing mocks and directives
under the global option and asserting vWrapper.html() === nWrapper.html();
reference mount, mountSuspended, defineComponent, Options and
mergeComponentMountingGlobalOptions to locate where to add them.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts`:
- Around line 601-622: Add explicit tests for global.mocks and global.directives
in this compatibility-mount.spec.ts suite similar to the existing
config.globalProperties test: create a small Component via defineComponent that
uses a mocked property (e.g., this.$mocked or a template reference) and a custom
directive (e.g., v-test that mutates DOM/text), then mount it with options typed
as Options<typeof Component> and compare outputs from mount(...) and await
mountSuspended(...). Ensure the tests exercise the
mergeComponentMountingGlobalOptions behavior by passing mocks and directives
under the global option and asserting vWrapper.html() === nWrapper.html();
reference mount, mountSuspended, defineComponent, Options and
mergeComponentMountingGlobalOptions to locate where to add them.

In `@src/runtime-utils/utils/suspended.ts`:
- Around line 231-238: The config merge currently only deep-merges
globalProperties and shallowly spreads options.config over defaults.config,
which will cause nested config objects (e.g., compilerOptions) to be overwritten
rather than merged; update the merge logic around config to deep-merge any
nested sub-objects you want preserved (at least include compilerOptions like
globalProperties) by merging defaults.config, options.config, and then
individually deep-merging nested keys such as globalProperties and
compilerOptions (referencing the existing defaults.config, options.config,
globalProperties, and compilerOptions symbols) so user-provided nested settings
are merged with defaults rather than replaced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 160f3bfa-3599-41d4-bf92-0a9baa1711d9

📥 Commits

Reviewing files that changed from the base of the PR and between c56f77a and 1a32dd0.

📒 Files selected for processing (5)
  • examples/app-vitest-full/components/InjectedValueComponent.vue
  • examples/app-vitest-full/plugins/inject-value.ts
  • examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts
  • examples/app-vitest-full/tests/nuxt/injected-value-component.spec.ts
  • src/runtime-utils/utils/suspended.ts

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 (1)
examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts (1)

586-590: Minor: el.textContent can be null in TypeScript.

Element.textContent has type string | null. While the test template guarantees content exists, adding a non-null assertion or fallback would be more defensive.

♻️ Proposed fix
           directives: {
             repeatText: {
               beforeMount(el: Element, { value }: { value: number }) {
-                el.textContent = el.textContent.repeat(value)
+                el.textContent = (el.textContent ?? '').repeat(value)
               },
             },
           },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts` around lines
586 - 590, The custom directive repeatText's beforeMount handler uses
el.textContent which is typed as string | null; update the handler
(repeatText.beforeMount) to guard against null by either using a non-null
assertion (el.textContent!) or providing a fallback (e.g., (el.textContent ??
'') ) before calling .repeat(value) so TypeScript no longer reports a possible
null access.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts`:
- Around line 586-590: The custom directive repeatText's beforeMount handler
uses el.textContent which is typed as string | null; update the handler
(repeatText.beforeMount) to guard against null by either using a non-null
assertion (el.textContent!) or providing a fallback (e.g., (el.textContent ??
'') ) before calling .repeat(value) so TypeScript no longer reports a possible
null access.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ed374b8-dd88-44f0-b6a4-ab4b8809d53a

📥 Commits

Reviewing files that changed from the base of the PR and between 1a32dd0 and 370e000.

📒 Files selected for processing (1)
  • examples/app-vitest-full/tests/nuxt/compatibility-mount.spec.ts

@danielroe danielroe changed the title fix(runtime-utils): align merging of mounting options with vue/test-utils for mount + render helpers fix(runtime-utils): align mount options merge w/ vue-test-utils Mar 15, 2026
@danielroe danielroe merged commit 27e34a9 into nuxt:main Mar 15, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 14, 2026
@yamachi4416 yamachi4416 deleted the fix/stubbed-global-provide branch March 15, 2026 10:00
@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.

2 participants

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