Skip to content

feat(ui): migrate jest from babel-jest to @swc/jest#112895

Open
scttcper wants to merge 30 commits intomasterfrom
scttcper/jest-swc-mocks-ui-tests
Open

feat(ui): migrate jest from babel-jest to @swc/jest#112895
scttcper wants to merge 30 commits intomasterfrom
scttcper/jest-swc-mocks-ui-tests

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented Apr 14, 2026

Replaces babel-jest with @swc/jest for test transformation. Adds CI caching for the transform cache. The magic comes from @swc-contrib/mut-cjs-exports that lets us continue to abuse cjs to mutate anything we want via spy etc.

Shard babel-jest swc Delta
0 368s 311s -57s
1 375s 323s -52s
2 347s 350s +3s
3 403s 352s -51s

running a single test locally with a warm cache slightly improves
CI=true pnpm t static/app/views/seerExplorer/explorerPanel.spec.tsx
3.73s user 3.09s system 154% cpu 4.402 total -> 3.31s user 2.82s system 152% cpu 4.026 total

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 14, 2026
@scttcper scttcper changed the title test(ui): migrate jest tests to swc-safe mocking ref(ui): migrate jest from babel-jest to @swc/jest Apr 14, 2026
@scttcper scttcper changed the title ref(ui): migrate jest from babel-jest to @swc/jest feat(ui): migrate jest from babel-jest to @swc/jest Apr 14, 2026
@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Apr 14, 2026

Sentry Snapshot Testing

Name Added Removed Modified Renamed Unchanged Status
sentry-frontend
sentry-frontend
0 0 0 0 204 ✅ Unchanged

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@scttcper scttcper marked this pull request as ready for review April 14, 2026 17:48
@scttcper scttcper requested review from a team as code owners April 14, 2026 17:48
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7bd701d. Configure here.

jest.config.ts Outdated
transform: {
'^.+\\.jsx?$': ['babel-jest', babelConfig as any],
'^.+\\.tsx?$': ['babel-jest', babelConfig as any],
'^.+\\.[mc]?[jt]sx?$': ['@swc/jest', swcConfig as any],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing mjs transform pattern in snapshot config

Low Severity

The old main config had a separate '^.+\\.mjs?$' transform entry for babel-jest, but .mjs files weren't matched by the old '^.+\\.jsx?$' or '^.+\\.tsx?$' patterns. The new single pattern '^.+\\.[mc]?[jt]sx?$' does correctly match .mjs, .mts, .cjs, .cts files — so this is actually fine and is an improvement. No bug here upon closer inspection.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7bd701d. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components 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