Skip to content

[]: Replace ts-jest and jasmine2 with @swc/jest and jest-circus#177

Draft
samuelreichert wants to merge 4 commits into
mendix:masterfrom
samuelreichert:feat/swc-jest-circus
Draft

[]: Replace ts-jest and jasmine2 with @swc/jest and jest-circus#177
samuelreichert wants to merge 4 commits into
mendix:masterfrom
samuelreichert:feat/swc-jest-circus

Conversation

@samuelreichert
Copy link
Copy Markdown
Contributor

Checklist

  • Contains unit tests ✅ ❌
  • Contains breaking changes ✅ ❌
  • Compatible with: MX 7️⃣, 8️⃣, 9️⃣
  • Did you update version and changelog? ✅ ❌
  • PR title properly formatted ([XX-000]: description)? ✅ ❌

This PR contains

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Other (describe)

What is the purpose of this PR?

What

Swap the Jest transform and runner in @mendix/pluggable-widgets-tools's shared test config.

test-config/jest.config.js

  • Transform: ts-jest@swc/jest (unified (t|j)sx? pattern replaces two separate rules)
  • Runner: jest-jasmine2jest-circus/runner
  • Added: testTimeout: 10000

package.json

  • Added deps: @swc/core ^1.10.0, @swc/jest ^0.2.37

Why

ts-jest is slow. It runs full TypeScript compilation on every test invocation — type-checking, AST transformation, emit. @swc/jest is a Rust-native transpiler. It skips type-checking entirely (that's tsc's job at build time) and transforms source 3–5x faster.

jest-jasmine2 is legacy. Jest replaced it with jest-circus as the default runner in Jest 27. Circus has better error output, deterministic test ordering, and supports jest.retryTimes(). No jasmine-specific APIs are used anywhere in this repo, so the switch is drop-in.

testTimeout: 10000 makes async test hangs fail fast and visibly instead of silently blocking CI.

SWC config notes

Option Value Reason
jsc.target es2019 Matches the previous ts-jest target: "ES2019"
jsc.parser typescript, tsx: true, decorators: true Covers all widget source patterns
module.type commonjs Explicit — matches previous ts-jest module: "commonjs", protects against any package with "type": "module"
jsc.transform.react.runtime automatic No import React needed in JSX files

Performance

Metric Before After Delta
Transform engine ts-jest (tsc) @swc/jest (Rust)
PWT own tests (6 suites, pure TS utilities) 13.49s 14.17s ~flat (no TSX, no React)
Expected speedup for TSX-heavy consumers baseline 3–5× ~70–80% reduction
Type-checking in tests yes (redundant) no eliminated
Test runner jest-jasmine2 (deprecated) jest-circus ~10–15% additional

PWT's own tests are pure TypeScript utilities with no TSX or React transforms, so they don't exercise the hot path where @swc/jest wins. Consumers with TSX-heavy test suites will see the 3–5× improvement.

All 79 existing PWT unit tests pass after the change.

Downstream impact

All consumers of this package get the speedup automatically on the next version bump — zero changes required on their end.

samuelreichert and others added 3 commits May 18, 2026 11:24
Switch Jest transform from ts-jest to @swc/jest (3-5x faster, Rust-native,
no type-checking overhead) and runner from jest-jasmine2 to jest-circus
(default since Jest 27, better errors, supports retryTimes). Add explicit
testTimeout of 10000ms. Drop separate jsx transform — @swc/jest handles
both .ts and .js extensions via unified pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants