phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Updating ts or jest seems to break tests

Open EdwardMoyse opened this issue 5 months ago • 9 comments

If I update either typescript or jest, then it seems the CI tests fail.

EdwardMoyse avatar Jul 09 '25 15:07 EdwardMoyse

Greetings @EdwardMoyse

I've reviewed the issue ,this often happens due to version incompatibilities or changes in type definitions and Jest configuration defaults between releases. To resolve this, I plan to: Pin compatible versions of TypeScript and Jest aligned with the project dependencies...

I'm eager to work on this issue. Hopeful for your consideration..

Thanks.

Sahilll10 avatar Oct 31 '25 12:10 Sahilll10

Please feel free! I'm currently very busy with other tasks and so all help with Phoenix is much appreciated.

On Fri, 31 Oct 2025 at 13:52, Sahil Kumar @.***> wrote:

Sahilll10 left a comment (HSF/phoenix#724) https://github.com/HSF/phoenix/issues/724#issuecomment-3472972325

Greetings @EdwardMoyse https://github.com/EdwardMoyse

I've reviewed the issue ,this often happens due to version incompatibilities or changes in type definitions and Jest configuration defaults between releases. To resolve this, I plan to: Pin compatible versions of TypeScript and Jest aligned with the project dependencies...

I'm eager to work on this issue. Hopeful for your consideration..

Thanks.

— Reply to this email directly, view it on GitHub https://github.com/HSF/phoenix/issues/724#issuecomment-3472972325, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTTQSOCHWU6A3F3XP56EH332NLR3AVCNFSM6AAAAACBENGF4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINZSHE3TEMZSGU . You are receiving this because you were mentioned.Message ID: @.***>

EdwardMoyse avatar Oct 31 '25 14:10 EdwardMoyse

Please see: https://github.com/HSF/phoenix/actions/runs/19042828188/job/54383831065?pr=729

Here we have a concrete example of what is going wrong:

   FAIL  src/tests/loaders/objects/phoenix-objects.test.ts
    ● Test suite failed to run
  
      Jest encountered an unexpected token
  
      Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
  
      Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
  
      By default "node_modules" folder is ignored by transformers.

EdwardMoyse avatar Nov 03 '25 17:11 EdwardMoyse

Greetings @EdwardMoyse

I reviewed your comment, and came with an idea.

The test failures were caused by ESM dependencies being loaded by Jest without being transformed. Jest supports Babel, but by default it does not apply transformations inside "node_modules", which leads to the "Jest encountered an unexpected token" error.

This update enables Babel-based transformation for ESM packages by:

  • Adding a Babel config ("babel-jest") to support such syntax.
  • Allowing Jest to transform selected ESM packages in "node_modules" so that this folder does not get ignored by transformers.

I guess this should work without failing and willing to do any changes in my approach. I'm eager to work on this issue under you. Hopeful for your consideration..

Thanks.

joyy-7921 avatar Nov 07 '25 05:11 joyy-7921

Hi @joyy-7921

I think that we are setup to use ts-jest rather than babel, but I have to confess I'm not too sure about this.

You can reproduce this failure by:

git clean -fdx
git switch main-update-angular
yarn install
yarn test:ci

EdwardMoyse avatar Nov 07 '25 07:11 EdwardMoyse

Hi @EdwardMoyse,

Sorry for the late response — I had an emergency situation to handle.

I understand what you meant. I’ll proceed with the ts-jest setup. Since the project is already TypeScript-based, using ts-jest keeps compilation and Jest transformation aligned with the existing TypeScript configuration, and avoids the inconsistencies that can come up when introducing Babel as a parallel pipeline.

I’ll update the Jest config to switch to ts-jest and adjust the transformIgnorePatterns to properly handle the three/examples ESM imports.

If this approach seems correct to you, could you please assign the issue to me? I’ll take it from here.

Thanks.

joyy-7921 avatar Nov 11 '25 13:11 joyy-7921

Hi @EdwardMoyse,

I've completed the assigned tasks and opened a PR to address the issues. Here's a summary:

Removed Angular dependency from phoenix-event-display

  • Created a framework-independent EventEmitter to replace Angular's EventEmitter
  • The library is now truly framework-agnostic

Fixed all test failures

  • Fixed Jest configuration issues
  • Added comprehensive mocks for three.js ESM modules
  • All 345 tests now passing (83/83 test suites) across both packages

Fixed integration with phoenix-ng

  • Updated tests and imports to work with the new EventEmitter
  • Verified full compatibility between packages

Results

  • Before: 0% tests passing, Angular dependency in core library
  • After: 100% tests passing (345/345), fully framework-agnostic

PR Link

https://github.com/HSF/phoenix/pull/735

The changes are backward compatible with no breaking changes. All tests pass successfully with yarn test:ci.

Let me know if you would like me to make any adjustments!

Thanks for the opportunity.

joyy-7921 avatar Nov 12 '25 09:11 joyy-7921

Hi @EdwardMoyse , I just wanted to let you know that I’m dealing with an emergency situation at home and won’t be able to work on this issue for about two weeks. I just wanted to keep you informed — I’ll resume as soon as things settle down.

Thanks for understanding.

joyy-7921 avatar Nov 14 '25 11:11 joyy-7921

Hi @EdwardMoyse , I just wanted to let you know that I’m dealing with an emergency situation at home and won’t be able to work on this issue for about two weeks. I just wanted to keep you informed — I’ll resume as soon as things settle down.

Thanks for understanding.

No problem - family first, always. But thanks for letting me know.

EdwardMoyse avatar Nov 14 '25 12:11 EdwardMoyse

Hello @EdwardMoyse ,

Two weeks ago, I informed you that I would be unavailable for some time, and thank you for acknowledging that. I wanted to let you know that I resumed work day before yesterday.

I have already pushed new commits to the pull request(#735) and waiting for the approval. I also have started working on the other issue (#666) assigned to me. I will continue making steady progress.

Thank you for the opportunity to contribute.

joyy-7921 avatar Nov 26 '25 14:11 joyy-7921