ESM error when trying to import Map from "@arcgis/core/Map" from ESRI JSAPI v4.20 on CRA

09-08-2021 05:13 AM
New Contributor II


I am trying to write tests using the create react app example and am getting the following error:  



To reproduce the error: 

-  `git clone`

- npm i

- go to create-react-app example 

- add `import Map from "@arcgis/core/Map";`

- replace "MapView" with "Map"

- `npm run test`


Any help would be much appreciated!

0 Kudos
1 Reply
Frequent Contributor II

If you add new ArcGIS imports into modules you're testing or change them, you need to add new mocks as well. The mocks are located here.

You might be able to use transformIgnorePatterns, but I couldn't get it to work with CRA.

Might need some more jest config options. It works in this angular demo, but CRA complains about some stuff.

0 Kudos