ngxs / store

🚀 NGXS - State Management for Angular
http://ngxs.io
MIT License
3.54k stars 406 forks source link

🐞[BUG]: it seems that Ngxs is not compatible with Jest ESM #2061

Closed vojtesaak closed 5 months ago

vojtesaak commented 1 year ago

Affected Package

@ngxs/store

Description

Tests run without ESM. If ESM is enabled, it ends up with error at the file with the NGXS import - it fails when requiring angular.

  ● Test suite failed to run

    Must use import to load ES Module: /Users/vojtesaak/imt/ngxs-esm/node_modules/@angular/core/fesm2022/core.mjs

      at Runtime.requireModule (node_modules/jest-runtime/build/index.js:850:21)
      at node_modules/@ngxs/store/bundles/ngxs-store.umd.js:2:85
      at Object.<anonymous> (node_modules/@ngxs/store/bundles/ngxs-store.umd.js:5:3)
          at async Promise.all (index 1)

🔬 Minimal Reproduction

https://github.com/vojtesaak/ngxs-esm

jase88 commented 11 months ago

Same error if using vitest with ngxs. Followed the setup here: https://dev.to/brandontroberts/faster-testing-with-angular-and-vitest-274n

So it seems to be ESM related

hunter-isaiah96 commented 11 months ago

Still running into this error, does anyone have a fix?

node_modules/@ngxs/store/bundles/ngxs-store.umd.js:2:83 ❯ Object. node_modules/@ngxs/store/bundles/ngxs-store.umd.js:5:3

theUgluk commented 6 months ago

I am still running into this, is this something that's known? Is there a workaround?

arturovt commented 5 months ago

Great news! v18.0.0 has been released and it includes a fix for this issue. We are closing this issue, but please re-open it if the issue is not resolved. Please leave a comment in the https://github.com/ngxs/store/discussions/2173 if you come across any regressions with respect to your issue.