Skip to content

Add test coverage for asset-without-sourcemap fallback to AST parsing#1453

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-asset-no-map-test-cases
Draft

Add test coverage for asset-without-sourcemap fallback to AST parsing#1453
Copilot wants to merge 3 commits intomainfrom
copilot/add-asset-no-map-test-cases

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

The fix in #1450 tracks assets without sourcemaps in assetsWithoutSourceMap set and triggers AST parsing as fallback. This PR adds missing test coverage.

Changes

Enhanced packages/core/tests/plugins/sourcemapTool.test.ts (+8 tests)

  • Verifies assetsWithoutSourceMap set population for JS/CSS assets with no sourcemap
  • Validates assets WITH sourcemap (inline or external) are excluded from tracking
  • Tests set clearing behavior on subsequent calls

New packages/graph/tests/transform/chunks/assetsModules.test.ts (+7 tests)

  • Confirms AST parsing is triggered only for tracked assets when assetsWithoutSourceMap is provided
  • Validates AST parsing fallback when no sourcemaps exist
  • Verifies AST parsing is skipped when all assets have sourcemaps
  • Tests mixed scenarios: assets with/without sourcemaps processed correctly

Test Coverage

// Assets without sourcemap are tracked
expect(plugin.assetsWithoutSourceMap.has('bundle.js')).toBe(true);

// Assets with sourcemap are NOT tracked
expect(plugin.assetsWithoutSourceMap.has('with-map.js')).toBe(false);

// AST parsing triggered only for tracked assets
expect(parseBundleCalled).toBe(true); // when assetsWithoutSourceMap provided
expect(parseBundleCalled).toBe(false); // when all assets have sourcemap

Total: 15 new tests, 215 tests passing

Original prompt

目前修复 PR 描述为:"fix: when the aseet no map will use parse module logic"。 为了补充这个修复的测试用例,我们需要确保代码逻辑在 'aseet 没有映射' 的情况下正确调用 'parse module logic'。

需要完成的任务:

  1. 写出能复现'asset no map'的测试数据。
  2. 验证修复逻辑的单元测试是否覆盖了新的代码路径。
  3. 在对应测试模块中编写新测试并断言结果符合预期。

请确保补充的测试用例充分验证了 "aseet no map" 使用 "parse module logic" 的边界情况。

This pull request was created as a result of the following prompt from Copilot chat.

目前修复 PR 描述为:"fix: when the aseet no map will use parse module logic"。 为了补充这个修复的测试用例,我们需要确保代码逻辑在 'aseet 没有映射' 的情况下正确调用 'parse module logic'。

需要完成的任务:

  1. 写出能复现'asset no map'的测试数据。
  2. 验证修复逻辑的单元测试是否覆盖了新的代码路径。
  3. 在对应测试模块中编写新测试并断言结果符合预期。

请确保补充的测试用例充分验证了 "aseet no map" 使用 "parse module logic" 的边界情况。


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for rsdoctor ready!

Name Link
🔨 Latest commit 6053fa2
🔍 Latest deploy log https://app.netlify.com/projects/rsdoctor/deploys/6940d5010f3ae800089c987b
😎 Deploy Preview https://deploy-preview-1453--rsdoctor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits December 16, 2025 03:37
Co-authored-by: yifancong <18437716+yifancong@users.noreply.github.com>
Co-authored-by: yifancong <18437716+yifancong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test cases for asset no map using parse module logic Add test coverage for asset-without-sourcemap fallback to AST parsing Dec 16, 2025
Copilot AI requested a review from yifancong December 16, 2025 03:45
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.

3 participants

Comments