Skip to content

perf(jest): Mock root ECharts imports#120049

Merged
scttcper merged 1 commit into
masterfrom
scttcper/mock-echarts-root
Jul 20, 2026
Merged

perf(jest): Mock root ECharts imports#120049
scttcper merged 1 commit into
masterfrom
scttcper/mock-echarts-root

Conversation

@scttcper

@scttcper scttcper commented Jul 20, 2026

Copy link
Copy Markdown
Member

The ECharts Jest mapper only matched subpaths, so root imports still loaded and transformed the real package. Match both the package root and subpaths to the lightweight mock, and expose the small root API surface tests use.

Benchmarking useChartXRangeSelection.spec.tsx over five cache-disabled runs:

Before After Improvement
4.530s median 4.125s median 405ms / 8.9%

This helps any Jest suite that reaches a root ECharts import by avoiding the real module work.

The existing mapper only catches ECharts subpaths, so root imports still load and transform the full package. Match the root export too and fill in the small API surface tests use.\n\nThe focused chart suite drops from a 4.530s median to 4.125s with Jest's cache disabled, about 9% faster.\n\nCo-Authored-By: Codex <noreply@openai.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 20, 2026
@scttcper
scttcper marked this pull request as ready for review July 20, 2026 15:36
@scttcper
scttcper requested review from a team as code owners July 20, 2026 15:36

@gggritso gggritso left a comment

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.

👍🏻 thank you!

@scttcper
scttcper merged commit 794af6a into master Jul 20, 2026
80 checks passed
@scttcper
scttcper deleted the scttcper/mock-echarts-root branch July 20, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants