Skip to content

fix: upgrade TypeScript to 5.7 with Jest ESM mocks#805

Open
remo-lab wants to merge 2 commits intoHSF:mainfrom
remo-lab:fix/jest-esm-three-compat
Open

fix: upgrade TypeScript to 5.7 with Jest ESM mocks#805
remo-lab wants to merge 2 commits intoHSF:mainfrom
remo-lab:fix/jest-esm-three-compat

Conversation

@remo-lab
Copy link
Contributor

Closes #724

Summary

This PR upgrades TypeScript to 5.7 across the monorepo and fixes Jest failures caused by ESM-only dependencies when running under ts-jest.

Changes include:

  • Upgraded TypeScript from ~5.5.4 to ~5.7.0 (root, phoenix-event-display, phoenix-ng)
  • Upgraded ts-jest to ^29.3.4 in phoenix-event-display
  • Added moduleNameMapper mocks for ESM-only dependencies that break Jest’s CommonJS pipeline on TS 5.6+

All 345 tests pass (28 + 56 suites, 170 + 175 tests) with yarn test:ci.


What was happening

With TypeScript 5.6+, Jest started failing due to .mjs files from ESM-only packages such as:

  • three/examples/jsm
  • jsroot
  • @angular/core

In my previous attempt (#768), I tried adjusting transformIgnorePatterns and consolidating TypeScript versions. That approach failed because:

  • <rootDir>/node_modules/... did not match hoisted workspace dependencies
  • As a result, all node_modules were being transformed by ts-jest
  • This happened to work on TS 5.5 but masked the real issue
  • After upgrading TS, ts-jest could no longer handle .mjs ESM modules correctly

Fix

Instead of trying to force ts-jest to transform ESM modules, this PR mocks them using moduleNameMapper.

Added mocks for:

  • three/examples/jsm/*
    WebGL-dependent modules not usable in jsdom anyway.

  • jsroot
    ESM-only modules imported transitively but not directly used in tests.

  • @angular/core
    Only EventEmitter is used; replaced with a lightweight publish/subscribe mock.

This avoids ESM parsing entirely and makes the test setup independent of TypeScript/Jest internals.


Test Plan

  • yarn test:ci passes (all 345 tests)
  • CI build-and-test workflow passes
  • Manually verified no runtime regressions in the Angular app

Signed-off-by: remo-lab <remopanda7@gmail.com>
@remo-lab remo-lab force-pushed the fix/jest-esm-three-compat branch from 0631587 to 7969ece Compare February 23, 2026 21:12
Signed-off-by: remo-lab <remopanda7@gmail.com>
@remo-lab
Copy link
Contributor Author

@EdwardMoyse , this time i have fixed all the ci failures.
The last empty commit was just to retrigger the CI — the previous run failed because of a GitHub API hiccup (invalid json response body), not any code issue. Everything was passing already, just needed a fresh run.All green now. would appreciate a review whenever you have time!

@remo-lab
Copy link
Contributor Author

@EdwardMoyse shall i update anything on this pr?

@EdwardMoyse
Copy link
Collaborator

Apologies for not being responsive but I'm on a family holiday this week. I'll try to do a review when im home on Sunday.

@remo-lab
Copy link
Contributor Author

No worries at all , thanks for letting me know. Hope you're having a great holiday!

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.

Updating ts or jest seems to break tests

2 participants