Hi,
I am trying to write tests using the create react app example and am getting the following error:
To reproduce the error:
- `git clone https://github.com/Esri/jsapi-resources.git`
- 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!
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.
https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app/src/__mocks__/%40arcgis/core
You might be able to use transformIgnorePatterns, but I couldn't get it to work with CRA.
https://jestjs.io/docs/configuration#transformignorepatterns-arraystring
Might need some more jest config options. It works in this angular demo, but CRA complains about some stuff.
https://github.com/andygup/angular-jsapi-jest
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.