Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still problems with Jest and ESM #9052

Closed
GeofoxCoding opened this issue Feb 21, 2022 · 2 comments
Closed

Still problems with Jest and ESM #9052

GeofoxCoding opened this issue Feb 21, 2022 · 2 comments
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@GeofoxCoding
Copy link

GeofoxCoding commented Feb 21, 2022

Current Behavior

In a fresh minimal angular workspace of current version I can't use a third party package which is built of ES modules and run tests with Jest.

> nx run main:test

 FAIL   main  apps/main/src/app/app.component.spec.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.
...
SyntaxError: Cannot use import statement outside a module

      1 | import { Component, OnInit, ViewEncapsulation } from '@angular/core';
      2 |
    > 3 | import WebMap from '@arcgis/core/WebMap';
        | ^

Expected Behavior

Because Jest is an important part of nx setup and more and more third party packages are built of ES modules we need support of such packages.

Steps to Reproduce

Although this problem has been discussed and documented a lot, I creates a repo again with our necessary dependency as an example.
https://github.com/GeofoxCoding/nx-esm-jest

run
npm install
nx test main

Is there any current solution how to get our dependency @arcgis/core working in Nx Jest setup?

@Coly010 Coly010 added the scope: angular Issues related to Angular support in Nx label Feb 22, 2022
@Coly010
Copy link
Contributor

Coly010 commented Feb 22, 2022

This is a duplicate of the following: #7844

There is a workaround here: #7844 (comment)

Closing as it's a duplicate

@Coly010 Coly010 closed this as completed Feb 22, 2022
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

2 participants