Skip to content

fix(runtime-utils): mockNuxtImport sourcemap mapped position - #1787

Open
yamachi4416 wants to merge 1 commit into
nuxt:mainfrom
yamachi4416:fix/mock-nuxt-import-sourcemap
Open

fix(runtime-utils): mockNuxtImport sourcemap mapped position#1787
yamachi4416 wants to merge 1 commit into
nuxt:mainfrom
yamachi4416:fix/mock-nuxt-import-sourcemap

Conversation

@yamachi4416

@yamachi4416 yamachi4416 commented Aug 22, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #1786

📚 Description

reproduction:
https://stackblitz.com/edit/nuxt-test-utils-issues-1786?file=package.json

AssertionError: expected 1 to be 999 // Object.is equality

- Expected
+ Received

- 999
+ 1

 ❯ test/nuxt/repro.test.ts:10:15
      8| describe('non-working example', () => {
      9|   it('source line numbers are incorrect when mockNuxtImport is called', () => {
     10|     expect(1).toBe(999)
       |               ^
     11|   })
     12| })

@pkg-pr-new

pkg-pr-new Bot commented Aug 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: c280f1b

@yamachi4416
yamachi4416 marked this pull request as ready for review August 22, 2026 16:31
@yamachi4416
yamachi4416 requested a review from danielroe as a code owner August 22, 2026 16:31
@coderabbitai

coderabbitai Bot commented Aug 22, 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 Plus

Run ID: f6e51939-69de-42a0-a614-b4c23da60065

📥 Commits

Reviewing files that changed from the base of the PR and between debaf18 and c280f1b.

📒 Files selected for processing (2)
  • src/module/plugins/mock.ts
  • test/unit/mock-transform.spec.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The mock plugin now generates high-resolution source maps in its Vite transform hook. Unit tests now resolve transformed code with source maps and verify generated and original positions for import-mocking and component-mocking scenarios.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c280f

This PR corrects the mapped source position for mockNuxtImport with localized implementation and test changes. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the source-map position fix for mockNuxtImport and accurately reflects the main change.
Description check ✅ Passed The description explains the source-map defect, links issue #1786, and provides a reproduction of the incorrect assertion position.
Linked Issues check ✅ Passed The change enables high-resolution source maps and adds position checks for mocked imports and components, addressing issue #1786.
Out of Scope Changes check ✅ Passed All changes support the source-map fix or its tests, with no unrelated code or behavioral changes identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.
✨ 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.

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.

mockNuxtImport corrupts source maps for nuxt tests

1 participant