Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough图像预处理器改用原始文件字节调用 Changes图像预处理流程
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Image imports in Jest now preserve original bytes and invalidate cached transforms when asset contents change, with coverage for supported image formats, ESM, CommonJS, large assets, and cache behavior. The change is ready to merge. Sequence Diagram(s)sequenceDiagram
participant Jest
participant imagePreprocessor
participant fs
participant url-loader
Jest->>imagePreprocessor: 调用 process(filename, options)
imagePreprocessor->>fs: readFileSync(filename)
fs-->>imagePreprocessor: 返回原始文件字节
imagePreprocessor->>url-loader: 传入字节与 esModule 选项
url-loader-->>imagePreprocessor: 返回数据 URL 模块代码
imagePreprocessor-->>Jest: 返回 code
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| expect(updated.stdout + updated.stderr).toContain('1 passed'); | ||
| expect(updated.status).toBe(0); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
You can remove tests/imagePreprocessor.test.js.
There was a problem hiding this comment.
Removed tests/imagePreprocessor.test.js in GitHub-Verified commit 9e010dc364763475398cf03ec4ef2db8e33187d1. The PR now changes only src/jest/imagePreprocessor.ts; the runtime source is unchanged. I reran all seven image regression cases before removing the file, then verified the remaining repository test, compile, ESLint, TypeScript and diff checks. The PR description now distinguishes this validation from the earlier Ant Design consumer run. Thanks!
Importing a local image through
imagePreprocessorcurrently emitsexport defaulteven when Jest expects CommonJS, sorequire('./image.png')fails withUnexpected token export. Jest also decodes files as UTF-8 before calling the transformer, corrupting binary image data. Assets above 10 KB reach a webpackfile-loaderfallback that cannot run in Jest.Read original image bytes, inline test assets without webpack file emission, and select CommonJS or ESM output using
supportsStaticESM. Hash original bytes for caching: different byte sequences can decode to the same text, otherwise allowing stale image content.Validation:
967174ed2189d39e6580dd5490039c04a43aa093. Removing only the new cache key causes the second binary-change Jest run to fail.The PR now changes only
src/jest/imagePreprocessor.ts, as requested. The removed regression source remains retrievable in prior commitb7fa700a92f60b3f679704caae4e59b80b10632a.Based directly on master and independent of #297. Implemented and validated with OpenAI Codex assistance.