Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NX 20.2.2 + Angular 19 + Ionic 8 + Jest : Broken tests following latest updates

I have been maintaining Ionic-Angular applications within an NX monorepo (without nxtend/nxext) for a while and it's been going well so far.

However, the last migration to NX 20.2.2 + Angular 19 has broken my Jest tests with those kind of errors:

    import { __awaiter } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

This was typically fixed in jest.config.ts by changing the "transformIgnorePattern" to include some packages from node_modules so that they are included in the ts-jest compilation.

  transformIgnorePatterns: ['/node_modules/(?!.*.mjs$|@ionic/core|@stencil/core|ionicons)'],

But the latest version has broken that and I don't know who the culprit is (NX, jest-preset-angular, my own configuration, something else?).

I've been trying to fix this with no success and I don't know where I should report a bug.

Can anyone help?

I'm including a simple project to reproduce the problem. By going through the commits, you can see the tests initally broken, then fixed, then broken after the migration.

Project: https://github.com/ddx001/nx-ng-ionic

To run, checkout the project and run:

npm install
npx nx run myapp:test
like image 653
ddx001 Avatar asked Sep 20 '25 04:09

ddx001


1 Answers

After some investigation, I found a really helpful thread with a solution: Jest fix for ionic/stencil

To make it short: downgrade typescript to ~5.5.x. This helped me and now the tests are running again. Looks like the issue is still not solved by Ionic.

But at least, it is a quick fix. And btw. I have the same setup as you.

like image 126
unos_mopsus Avatar answered Sep 22 '25 16:09

unos_mopsus